home *** CD-ROM | disk | FTP | other *** search
Unknown | 2014-12-31 | 59.4 KB |
view JSON data
|
view as text
|
open on a Mac
|
open on a PC
This file was not able to be converted.
This format is not currently supported by dexvert.
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| Python Compiled Bytecode (document/pythonCompiled)
| magic
| Supported |
100%
| file
| python 2.7 byte-compiled
| default
| |
99%
| file
| data
| default
| |
57%
| TrID
| CPython 2.7 bytecode
| default
| |
42%
| TrID
| Python optimized code
| default
| |
100%
| detectItEasy
| Format: Python Compiled Module(2.7a0)
| default
| |
100%
| detectItEasy
| Format: DBase Database (.DBF)
| default (weak)
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 03 f3 0d 0a 90 38 6d 52 | 63 00 00 00 00 00 00 00 |.....8mR|c.......|
|00000010| 00 0b 00 00 00 40 00 00 | 00 73 a5 01 00 00 64 00 |.....@..|.s....d.|
|00000020| 00 5a 00 00 64 01 00 64 | 02 00 64 03 00 64 04 00 |.Z..d..d|..d..d..|
|00000030| 64 05 00 64 06 00 64 07 | 00 64 08 00 64 09 00 64 |d..d..d.|.d..d..d|
|00000040| 0a 00 64 0b 00 67 0b 00 | 5a 01 00 64 0c 00 64 0d |..d..g..|Z..d..d.|
|00000050| 00 6c 02 00 5a 02 00 64 | 0c 00 64 0e 00 6c 03 00 |.l..Z..d|..d..l..|
|00000060| 6d 04 00 5a 05 00 01 64 | 0c 00 64 0f 00 6c 06 00 |m..Z...d|..d..l..|
|00000070| 6d 07 00 5a 07 00 01 65 | 05 00 64 0b 00 64 10 00 |m..Z...e|..d..d..|
|00000080| 83 02 00 5a 08 00 64 11 | 00 84 00 00 5a 09 00 64 |...Z..d.|....Z..d|
|00000090| 04 00 66 00 00 64 12 00 | 84 00 00 83 00 00 59 5a |..f..d..|......YZ|
|000000a0| 0a 00 64 13 00 64 14 00 | 64 15 00 84 02 00 5a 0b |..d..d..|d.....Z.|
|000000b0| 00 64 16 00 84 00 00 5a | 0c 00 64 05 00 66 00 00 |.d.....Z|..d..f..|
|000000c0| 64 17 00 84 00 00 83 00 | 00 59 5a 0d 00 64 0c 00 |d.......|.YZ..d..|
|000000d0| 64 0d 00 6c 0e 00 5a 0e | 00 65 0e 00 6a 0f 00 64 |d..l..Z.|.e..j..d|
|000000e0| 18 00 83 01 00 6a 10 00 | 64 19 00 84 01 00 5a 11 |.....j..|d.....Z.|
|000000f0| 00 64 1a 00 64 1b 00 84 | 01 00 5a 12 00 64 1c 00 |.d..d...|..Z..d..|
|00000100| 84 00 00 5a 13 00 64 1d | 00 64 1d 00 64 1d 00 64 |...Z..d.|.d..d..d|
|00000110| 1d 00 64 13 00 64 1e 00 | 64 1f 00 84 06 00 5a 14 |..d..d..|d.....Z.|
|00000120| 00 64 20 00 84 00 00 5a | 15 00 64 1d 00 64 1d 00 |.d ....Z|..d..d..|
|00000130| 64 1d 00 64 1d 00 64 13 | 00 64 1e 00 64 21 00 84 |d..d..d.|.d..d!..|
|00000140| 06 00 5a 16 00 65 17 00 | 65 12 00 64 22 00 84 02 |..Z..e..|e..d"...|
|00000150| 00 5a 18 00 65 17 00 65 | 17 00 65 12 00 64 23 00 |.Z..e..e|..e..d#.|
|00000160| 84 03 00 5a 19 00 64 24 | 00 5a 1a 00 64 25 00 5a |...Z..d$|.Z..d%.Z|
|00000170| 1b 00 64 26 00 5a 1c 00 | 64 27 00 5a 1d 00 64 0a |..d&.Z..|d'.Z..d.|
|00000180| 00 65 1e 00 66 01 00 64 | 28 00 84 00 00 83 00 00 |.e..f..d|(.......|
|00000190| 59 5a 1f 00 5b 0e 00 64 | 29 00 84 00 00 5a 20 00 |YZ..[..d|)....Z .|
|000001a0| 64 2a 00 84 00 00 5a 21 | 00 65 22 00 64 2b 00 6b |d*....Z!|.e".d+.k|
|000001b0| 02 00 72 a1 01 65 21 00 | 83 00 00 01 6e 00 00 64 |..r..e!.|....n..d|
|000001c0| 0d 00 53 28 2c 00 00 00 | 73 65 03 00 00 0a 4d 6f |..S(,...|se....Mo|
|000001d0| 64 75 6c 65 20 64 69 66 | 66 6c 69 62 20 2d 2d 20 |dule dif|flib -- |
|000001e0| 68 65 6c 70 65 72 73 20 | 66 6f 72 20 63 6f 6d 70 |helpers |for comp|
|000001f0| 75 74 69 6e 67 20 64 65 | 6c 74 61 73 20 62 65 74 |uting de|ltas bet|
|00000200| 77 65 65 6e 20 6f 62 6a | 65 63 74 73 2e 0a 0a 46 |ween obj|ects...F|
|00000210| 75 6e 63 74 69 6f 6e 20 | 67 65 74 5f 63 6c 6f 73 |unction |get_clos|
|00000220| 65 5f 6d 61 74 63 68 65 | 73 28 77 6f 72 64 2c 20 |e_matche|s(word, |
|00000230| 70 6f 73 73 69 62 69 6c | 69 74 69 65 73 2c 20 6e |possibil|ities, n|
|00000240| 3d 33 2c 20 63 75 74 6f | 66 66 3d 30 2e 36 29 3a |=3, cuto|ff=0.6):|
|00000250| 0a 20 20 20 20 55 73 65 | 20 53 65 71 75 65 6e 63 |. Use| Sequenc|
|00000260| 65 4d 61 74 63 68 65 72 | 20 74 6f 20 72 65 74 75 |eMatcher| to retu|
|00000270| 72 6e 20 6c 69 73 74 20 | 6f 66 20 74 68 65 20 62 |rn list |of the b|
|00000280| 65 73 74 20 22 67 6f 6f | 64 20 65 6e 6f 75 67 68 |est "goo|d enough|
|00000290| 22 20 6d 61 74 63 68 65 | 73 2e 0a 0a 46 75 6e 63 |" matche|s...Func|
|000002a0| 74 69 6f 6e 20 63 6f 6e | 74 65 78 74 5f 64 69 66 |tion con|text_dif|
|000002b0| 66 28 61 2c 20 62 29 3a | 0a 20 20 20 20 46 6f 72 |f(a, b):|. For|
|000002c0| 20 74 77 6f 20 6c 69 73 | 74 73 20 6f 66 20 73 74 | two lis|ts of st|
|000002d0| 72 69 6e 67 73 2c 20 72 | 65 74 75 72 6e 20 61 20 |rings, r|eturn a |
|000002e0| 64 65 6c 74 61 20 69 6e | 20 63 6f 6e 74 65 78 74 |delta in| context|
|000002f0| 20 64 69 66 66 20 66 6f | 72 6d 61 74 2e 0a 0a 46 | diff fo|rmat...F|
|00000300| 75 6e 63 74 69 6f 6e 20 | 6e 64 69 66 66 28 61 2c |unction |ndiff(a,|
|00000310| 20 62 29 3a 0a 20 20 20 | 20 52 65 74 75 72 6e 20 | b):. | Return |
|00000320| 61 20 64 65 6c 74 61 3a | 20 74 68 65 20 64 69 66 |a delta:| the dif|
|00000330| 66 65 72 65 6e 63 65 20 | 62 65 74 77 65 65 6e 20 |ference |between |
|00000340| 60 61 60 20 61 6e 64 20 | 60 62 60 20 28 6c 69 73 |`a` and |`b` (lis|
|00000350| 74 73 20 6f 66 20 73 74 | 72 69 6e 67 73 29 2e 0a |ts of st|rings)..|
|00000360| 0a 46 75 6e 63 74 69 6f | 6e 20 72 65 73 74 6f 72 |.Functio|n restor|
|00000370| 65 28 64 65 6c 74 61 2c | 20 77 68 69 63 68 29 3a |e(delta,| which):|
|00000380| 0a 20 20 20 20 52 65 74 | 75 72 6e 20 6f 6e 65 20 |. Ret|urn one |
|00000390| 6f 66 20 74 68 65 20 74 | 77 6f 20 73 65 71 75 65 |of the t|wo seque|
|000003a0| 6e 63 65 73 20 74 68 61 | 74 20 67 65 6e 65 72 61 |nces tha|t genera|
|000003b0| 74 65 64 20 61 6e 20 6e | 64 69 66 66 20 64 65 6c |ted an n|diff del|
|000003c0| 74 61 2e 0a 0a 46 75 6e | 63 74 69 6f 6e 20 75 6e |ta...Fun|ction un|
|000003d0| 69 66 69 65 64 5f 64 69 | 66 66 28 61 2c 20 62 29 |ified_di|ff(a, b)|
|000003e0| 3a 0a 20 20 20 20 46 6f | 72 20 74 77 6f 20 6c 69 |:. Fo|r two li|
|000003f0| 73 74 73 20 6f 66 20 73 | 74 72 69 6e 67 73 2c 20 |sts of s|trings, |
|00000400| 72 65 74 75 72 6e 20 61 | 20 64 65 6c 74 61 20 69 |return a| delta i|
|00000410| 6e 20 75 6e 69 66 69 65 | 64 20 64 69 66 66 20 66 |n unifie|d diff f|
|00000420| 6f 72 6d 61 74 2e 0a 0a | 43 6c 61 73 73 20 53 65 |ormat...|Class Se|
|00000430| 71 75 65 6e 63 65 4d 61 | 74 63 68 65 72 3a 0a 20 |quenceMa|tcher:. |
|00000440| 20 20 20 41 20 66 6c 65 | 78 69 62 6c 65 20 63 6c | A fle|xible cl|
|00000450| 61 73 73 20 66 6f 72 20 | 63 6f 6d 70 61 72 69 6e |ass for |comparin|
|00000460| 67 20 70 61 69 72 73 20 | 6f 66 20 73 65 71 75 65 |g pairs |of seque|
|00000470| 6e 63 65 73 20 6f 66 20 | 61 6e 79 20 74 79 70 65 |nces of |any type|
|00000480| 2e 0a 0a 43 6c 61 73 73 | 20 44 69 66 66 65 72 3a |...Class| Differ:|
|00000490| 0a 20 20 20 20 46 6f 72 | 20 70 72 6f 64 75 63 69 |. For| produci|
|000004a0| 6e 67 20 68 75 6d 61 6e | 2d 72 65 61 64 61 62 6c |ng human|-readabl|
|000004b0| 65 20 64 65 6c 74 61 73 | 20 66 72 6f 6d 20 73 65 |e deltas| from se|
|000004c0| 71 75 65 6e 63 65 73 20 | 6f 66 20 6c 69 6e 65 73 |quences |of lines|
|000004d0| 20 6f 66 20 74 65 78 74 | 2e 0a 0a 43 6c 61 73 73 | of text|...Class|
|000004e0| 20 48 74 6d 6c 44 69 66 | 66 3a 0a 20 20 20 20 46 | HtmlDif|f:. F|
|000004f0| 6f 72 20 70 72 6f 64 75 | 63 69 6e 67 20 48 54 4d |or produ|cing HTM|
|00000500| 4c 20 73 69 64 65 20 62 | 79 20 73 69 64 65 20 63 |L side b|y side c|
|00000510| 6f 6d 70 61 72 69 73 6f | 6e 20 77 69 74 68 20 63 |ompariso|n with c|
|00000520| 68 61 6e 67 65 20 68 69 | 67 68 6c 69 67 68 74 73 |hange hi|ghlights|
|00000530| 2e 0a 74 11 00 00 00 67 | 65 74 5f 63 6c 6f 73 65 |..t....g|et_close|
|00000540| 5f 6d 61 74 63 68 65 73 | 74 05 00 00 00 6e 64 69 |_matches|t....ndi|
|00000550| 66 66 74 07 00 00 00 72 | 65 73 74 6f 72 65 74 0f |fft....r|estoret.|
|00000560| 00 00 00 53 65 71 75 65 | 6e 63 65 4d 61 74 63 68 |...Seque|nceMatch|
|00000570| 65 72 74 06 00 00 00 44 | 69 66 66 65 72 74 11 00 |ert....D|iffert..|
|00000580| 00 00 49 53 5f 43 48 41 | 52 41 43 54 45 52 5f 4a |..IS_CHA|RACTER_J|
|00000590| 55 4e 4b 74 0c 00 00 00 | 49 53 5f 4c 49 4e 45 5f |UNKt....|IS_LINE_|
|000005a0| 4a 55 4e 4b 74 0c 00 00 | 00 63 6f 6e 74 65 78 74 |JUNKt...|.context|
|000005b0| 5f 64 69 66 66 74 0c 00 | 00 00 75 6e 69 66 69 65 |_difft..|..unifie|
|000005c0| 64 5f 64 69 66 66 74 08 | 00 00 00 48 74 6d 6c 44 |d_difft.|...HtmlD|
|000005d0| 69 66 66 74 05 00 00 00 | 4d 61 74 63 68 69 ff ff |ifft....|Matchi..|
|000005e0| ff ff 4e 28 01 00 00 00 | 74 0a 00 00 00 6e 61 6d |..N(....|t....nam|
|000005f0| 65 64 74 75 70 6c 65 28 | 01 00 00 00 74 06 00 00 |edtuple(|....t...|
|00000600| 00 72 65 64 75 63 65 73 | 08 00 00 00 61 20 62 20 |.reduces|....a b |
|00000610| 73 69 7a 65 63 02 00 00 | 00 02 00 00 00 02 00 00 |sizec...|........|
|00000620| 00 43 00 00 00 73 16 00 | 00 00 7c 01 00 72 12 00 |.C...s..|..|..r..|
|00000630| 64 01 00 7c 00 00 14 7c | 01 00 15 53 64 02 00 53 |d..|...||...Sd..S|
|00000640| 28 03 00 00 00 4e 67 00 | 00 00 00 00 00 00 40 67 |(....Ng.|......@g|
|00000650| 00 00 00 00 00 00 f0 3f | 28 00 00 00 00 28 02 00 |.......?|(....(..|
|00000660| 00 00 74 07 00 00 00 6d | 61 74 63 68 65 73 74 06 |..t....m|atchest.|
|00000670| 00 00 00 6c 65 6e 67 74 | 68 28 00 00 00 00 28 00 |...lengt|h(....(.|
|00000680| 00 00 00 73 0b 00 00 00 | 64 69 66 66 6c 69 62 2e |...s....|difflib.|
|00000690| 70 79 63 74 10 00 00 00 | 5f 63 61 6c 63 75 6c 61 |pyct....|_calcula|
|000006a0| 74 65 5f 72 61 74 69 6f | 29 00 00 00 73 06 00 00 |te_ratio|)...s...|
|000006b0| 00 00 01 06 01 0c 01 63 | 00 00 00 00 00 00 00 00 |.......c|........|
|000006c0| 05 00 00 00 42 00 00 00 | 73 89 00 00 00 65 00 00 |....B...|s....e..|
|000006d0| 5a 01 00 64 00 00 5a 02 | 00 64 0f 00 64 01 00 64 |Z..d..Z.|.d..d..d|
|000006e0| 01 00 65 04 00 64 02 00 | 84 04 00 5a 05 00 64 03 |..e..d..|...Z..d.|
|000006f0| 00 84 00 00 5a 06 00 64 | 04 00 84 00 00 5a 07 00 |....Z..d|.....Z..|
|00000700| 64 05 00 84 00 00 5a 08 | 00 64 06 00 84 00 00 5a |d.....Z.|.d.....Z|
|00000710| 09 00 64 07 00 84 00 00 | 5a 0a 00 64 08 00 84 00 |..d.....|Z..d....|
|00000720| 00 5a 0b 00 64 09 00 84 | 00 00 5a 0c 00 64 0a 00 |.Z..d...|..Z..d..|
|00000730| 64 0b 00 84 01 00 5a 0d | 00 64 0c 00 84 00 00 5a |d.....Z.|.d.....Z|
|00000740| 0e 00 64 0d 00 84 00 00 | 5a 0f 00 64 0e 00 84 00 |..d.....|Z..d....|
|00000750| 00 5a 10 00 52 53 28 10 | 00 00 00 73 9d 10 00 00 |.Z..RS(.|...s....|
|00000760| 0a 20 20 20 20 53 65 71 | 75 65 6e 63 65 4d 61 74 |. Seq|uenceMat|
|00000770| 63 68 65 72 20 69 73 20 | 61 20 66 6c 65 78 69 62 |cher is |a flexib|
|00000780| 6c 65 20 63 6c 61 73 73 | 20 66 6f 72 20 63 6f 6d |le class| for com|
|00000790| 70 61 72 69 6e 67 20 70 | 61 69 72 73 20 6f 66 20 |paring p|airs of |
|000007a0| 73 65 71 75 65 6e 63 65 | 73 20 6f 66 0a 20 20 20 |sequence|s of. |
|000007b0| 20 61 6e 79 20 74 79 70 | 65 2c 20 73 6f 20 6c 6f | any typ|e, so lo|
|000007c0| 6e 67 20 61 73 20 74 68 | 65 20 73 65 71 75 65 6e |ng as th|e sequen|
|000007d0| 63 65 20 65 6c 65 6d 65 | 6e 74 73 20 61 72 65 20 |ce eleme|nts are |
|000007e0| 68 61 73 68 61 62 6c 65 | 2e 20 20 54 68 65 20 62 |hashable|. The b|
|000007f0| 61 73 69 63 0a 20 20 20 | 20 61 6c 67 6f 72 69 74 |asic. | algorit|
|00000800| 68 6d 20 70 72 65 64 61 | 74 65 73 2c 20 61 6e 64 |hm preda|tes, and|
|00000810| 20 69 73 20 61 20 6c 69 | 74 74 6c 65 20 66 61 6e | is a li|ttle fan|
|00000820| 63 69 65 72 20 74 68 61 | 6e 2c 20 61 6e 20 61 6c |cier tha|n, an al|
|00000830| 67 6f 72 69 74 68 6d 0a | 20 20 20 20 70 75 62 6c |gorithm.| publ|
|00000840| 69 73 68 65 64 20 69 6e | 20 74 68 65 20 6c 61 74 |ished in| the lat|
|00000850| 65 20 31 39 38 30 27 73 | 20 62 79 20 52 61 74 63 |e 1980's| by Ratc|
|00000860| 6c 69 66 66 20 61 6e 64 | 20 4f 62 65 72 73 68 65 |liff and| Obershe|
|00000870| 6c 70 20 75 6e 64 65 72 | 20 74 68 65 0a 20 20 20 |lp under| the. |
|00000880| 20 68 79 70 65 72 62 6f | 6c 69 63 20 6e 61 6d 65 | hyperbo|lic name|
|00000890| 20 22 67 65 73 74 61 6c | 74 20 70 61 74 74 65 72 | "gestal|t patter|
|000008a0| 6e 20 6d 61 74 63 68 69 | 6e 67 22 2e 20 20 54 68 |n matchi|ng". Th|
|000008b0| 65 20 62 61 73 69 63 20 | 69 64 65 61 20 69 73 20 |e basic |idea is |
|000008c0| 74 6f 20 66 69 6e 64 0a | 20 20 20 20 74 68 65 20 |to find.| the |
|000008d0| 6c 6f 6e 67 65 73 74 20 | 63 6f 6e 74 69 67 75 6f |longest |contiguo|
|000008e0| 75 73 20 6d 61 74 63 68 | 69 6e 67 20 73 75 62 73 |us match|ing subs|
|000008f0| 65 71 75 65 6e 63 65 20 | 74 68 61 74 20 63 6f 6e |equence |that con|
|00000900| 74 61 69 6e 73 20 6e 6f | 20 22 6a 75 6e 6b 22 0a |tains no| "junk".|
|00000910| 20 20 20 20 65 6c 65 6d | 65 6e 74 73 20 28 52 2d | elem|ents (R-|
|00000920| 4f 20 64 6f 65 73 6e 27 | 74 20 61 64 64 72 65 73 |O doesn'|t addres|
|00000930| 73 20 6a 75 6e 6b 29 2e | 20 20 54 68 65 20 73 61 |s junk).| The sa|
|00000940| 6d 65 20 69 64 65 61 20 | 69 73 20 74 68 65 6e 20 |me idea |is then |
|00000950| 61 70 70 6c 69 65 64 0a | 20 20 20 20 72 65 63 75 |applied.| recu|
|00000960| 72 73 69 76 65 6c 79 20 | 74 6f 20 74 68 65 20 70 |rsively |to the p|
|00000970| 69 65 63 65 73 20 6f 66 | 20 74 68 65 20 73 65 71 |ieces of| the seq|
|00000980| 75 65 6e 63 65 73 20 74 | 6f 20 74 68 65 20 6c 65 |uences t|o the le|
|00000990| 66 74 20 61 6e 64 20 74 | 6f 20 74 68 65 20 72 69 |ft and t|o the ri|
|000009a0| 67 68 74 0a 20 20 20 20 | 6f 66 20 74 68 65 20 6d |ght. |of the m|
|000009b0| 61 74 63 68 69 6e 67 20 | 73 75 62 73 65 71 75 65 |atching |subseque|
|000009c0| 6e 63 65 2e 20 20 54 68 | 69 73 20 64 6f 65 73 20 |nce. Th|is does |
|000009d0| 6e 6f 74 20 79 69 65 6c | 64 20 6d 69 6e 69 6d 61 |not yiel|d minima|
|000009e0| 6c 20 65 64 69 74 0a 20 | 20 20 20 73 65 71 75 65 |l edit. | seque|
|000009f0| 6e 63 65 73 2c 20 62 75 | 74 20 64 6f 65 73 20 74 |nces, bu|t does t|
|00000a00| 65 6e 64 20 74 6f 20 79 | 69 65 6c 64 20 6d 61 74 |end to y|ield mat|
|00000a10| 63 68 65 73 20 74 68 61 | 74 20 22 6c 6f 6f 6b 20 |ches tha|t "look |
|00000a20| 72 69 67 68 74 22 20 74 | 6f 20 70 65 6f 70 6c 65 |right" t|o people|
|00000a30| 2e 0a 0a 20 20 20 20 53 | 65 71 75 65 6e 63 65 4d |... S|equenceM|
|00000a40| 61 74 63 68 65 72 20 74 | 72 69 65 73 20 74 6f 20 |atcher t|ries to |
|00000a50| 63 6f 6d 70 75 74 65 20 | 61 20 22 68 75 6d 61 6e |compute |a "human|
|00000a60| 2d 66 72 69 65 6e 64 6c | 79 20 64 69 66 66 22 20 |-friendl|y diff" |
|00000a70| 62 65 74 77 65 65 6e 20 | 74 77 6f 0a 20 20 20 20 |between |two. |
|00000a80| 73 65 71 75 65 6e 63 65 | 73 2e 20 20 55 6e 6c 69 |sequence|s. Unli|
|00000a90| 6b 65 20 65 2e 67 2e 20 | 55 4e 49 58 28 74 6d 29 |ke e.g. |UNIX(tm)|
|00000aa0| 20 64 69 66 66 2c 20 74 | 68 65 20 66 75 6e 64 61 | diff, t|he funda|
|00000ab0| 6d 65 6e 74 61 6c 20 6e | 6f 74 69 6f 6e 20 69 73 |mental n|otion is|
|00000ac0| 20 74 68 65 0a 20 20 20 | 20 6c 6f 6e 67 65 73 74 | the. | longest|
|00000ad0| 20 2a 63 6f 6e 74 69 67 | 75 6f 75 73 2a 20 26 20 | *contig|uous* & |
|00000ae0| 6a 75 6e 6b 2d 66 72 65 | 65 20 6d 61 74 63 68 69 |junk-fre|e matchi|
|00000af0| 6e 67 20 73 75 62 73 65 | 71 75 65 6e 63 65 2e 20 |ng subse|quence. |
|00000b00| 20 54 68 61 74 27 73 20 | 77 68 61 74 0a 20 20 20 | That's |what. |
|00000b10| 20 63 61 74 63 68 65 73 | 20 70 65 6f 70 6c 65 73 | catches| peoples|
|00000b20| 27 20 65 79 65 73 2e 20 | 20 54 68 65 20 57 69 6e |' eyes. | The Win|
|00000b30| 64 6f 77 73 28 74 6d 29 | 20 77 69 6e 64 69 66 66 |dows(tm)| windiff|
|00000b40| 20 68 61 73 20 61 6e 6f | 74 68 65 72 20 69 6e 74 | has ano|ther int|
|00000b50| 65 72 65 73 74 69 6e 67 | 0a 20 20 20 20 6e 6f 74 |eresting|. not|
|00000b60| 69 6f 6e 2c 20 70 61 69 | 72 69 6e 67 20 75 70 20 |ion, pai|ring up |
|00000b70| 65 6c 65 6d 65 6e 74 73 | 20 74 68 61 74 20 61 70 |elements| that ap|
|00000b80| 70 65 61 72 20 75 6e 69 | 71 75 65 6c 79 20 69 6e |pear uni|quely in|
|00000b90| 20 65 61 63 68 20 73 65 | 71 75 65 6e 63 65 2e 0a | each se|quence..|
|00000ba0| 20 20 20 20 54 68 61 74 | 2c 20 61 6e 64 20 74 68 | That|, and th|
|00000bb0| 65 20 6d 65 74 68 6f 64 | 20 68 65 72 65 2c 20 61 |e method| here, a|
|00000bc0| 70 70 65 61 72 20 74 6f | 20 79 69 65 6c 64 20 6d |ppear to| yield m|
|00000bd0| 6f 72 65 20 69 6e 74 75 | 69 74 69 76 65 20 64 69 |ore intu|itive di|
|00000be0| 66 66 65 72 65 6e 63 65 | 0a 20 20 20 20 72 65 70 |fference|. rep|
|00000bf0| 6f 72 74 73 20 74 68 61 | 6e 20 64 6f 65 73 20 64 |orts tha|n does d|
|00000c00| 69 66 66 2e 20 20 54 68 | 69 73 20 6d 65 74 68 6f |iff. Th|is metho|
|00000c10| 64 20 61 70 70 65 61 72 | 73 20 74 6f 20 62 65 20 |d appear|s to be |
|00000c20| 74 68 65 20 6c 65 61 73 | 74 20 76 75 6c 6e 65 72 |the leas|t vulner|
|00000c30| 61 62 6c 65 0a 20 20 20 | 20 74 6f 20 73 79 6e 63 |able. | to sync|
|00000c40| 68 69 6e 67 20 75 70 20 | 6f 6e 20 62 6c 6f 63 6b |hing up |on block|
|00000c50| 73 20 6f 66 20 22 6a 75 | 6e 6b 20 6c 69 6e 65 73 |s of "ju|nk lines|
|00000c60| 22 2c 20 74 68 6f 75 67 | 68 20 28 6c 69 6b 65 20 |", thoug|h (like |
|00000c70| 62 6c 61 6e 6b 20 6c 69 | 6e 65 73 20 69 6e 0a 20 |blank li|nes in. |
|00000c80| 20 20 20 6f 72 64 69 6e | 61 72 79 20 74 65 78 74 | ordin|ary text|
|00000c90| 20 66 69 6c 65 73 2c 20 | 6f 72 20 6d 61 79 62 65 | files, |or maybe|
|00000ca0| 20 22 3c 50 3e 22 20 6c | 69 6e 65 73 20 69 6e 20 | "<P>" l|ines in |
|00000cb0| 48 54 4d 4c 20 66 69 6c | 65 73 29 2e 20 20 54 68 |HTML fil|es). Th|
|00000cc0| 61 74 20 6d 61 79 20 62 | 65 0a 20 20 20 20 62 65 |at may b|e. be|
|00000cd0| 63 61 75 73 65 20 74 68 | 69 73 20 69 73 20 74 68 |cause th|is is th|
|00000ce0| 65 20 6f 6e 6c 79 20 6d | 65 74 68 6f 64 20 6f 66 |e only m|ethod of|
|00000cf0| 20 74 68 65 20 33 20 74 | 68 61 74 20 68 61 73 20 | the 3 t|hat has |
|00000d00| 61 20 2a 63 6f 6e 63 65 | 70 74 2a 20 6f 66 0a 20 |a *conce|pt* of. |
|00000d10| 20 20 20 22 6a 75 6e 6b | 22 20 3c 77 69 6e 6b 3e | "junk|" <wink>|
|00000d20| 2e 0a 0a 20 20 20 20 45 | 78 61 6d 70 6c 65 2c 20 |... E|xample, |
|00000d30| 63 6f 6d 70 61 72 69 6e | 67 20 74 77 6f 20 73 74 |comparin|g two st|
|00000d40| 72 69 6e 67 73 2c 20 61 | 6e 64 20 63 6f 6e 73 69 |rings, a|nd consi|
|00000d50| 64 65 72 69 6e 67 20 62 | 6c 61 6e 6b 73 20 74 6f |dering b|lanks to|
|00000d60| 20 62 65 20 22 6a 75 6e | 6b 22 3a 0a 0a 20 20 20 | be "jun|k":.. |
|00000d70| 20 3e 3e 3e 20 73 20 3d | 20 53 65 71 75 65 6e 63 | >>> s =| Sequenc|
|00000d80| 65 4d 61 74 63 68 65 72 | 28 6c 61 6d 62 64 61 20 |eMatcher|(lambda |
|00000d90| 78 3a 20 78 20 3d 3d 20 | 22 20 22 2c 0a 20 20 20 |x: x == |" ",. |
|00000da0| 20 2e 2e 2e 20 20 20 20 | 20 20 20 20 20 20 20 20 | ... | |
|00000db0| 20 20 20 20 20 20 20 20 | 20 22 70 72 69 76 61 74 | | "privat|
|00000dc0| 65 20 54 68 72 65 61 64 | 20 63 75 72 72 65 6e 74 |e Thread| current|
|00000dd0| 54 68 72 65 61 64 3b 22 | 2c 0a 20 20 20 20 2e 2e |Thread;"|,. ..|
|00000de0| 2e 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |. | |
|00000df0| 20 20 20 20 20 20 22 70 | 72 69 76 61 74 65 20 76 | "p|rivate v|
|00000e00| 6f 6c 61 74 69 6c 65 20 | 54 68 72 65 61 64 20 63 |olatile |Thread c|
|00000e10| 75 72 72 65 6e 74 54 68 | 72 65 61 64 3b 22 29 0a |urrentTh|read;").|
|00000e20| 20 20 20 20 3e 3e 3e 0a | 0a 20 20 20 20 2e 72 61 | >>>.|. .ra|
|00000e30| 74 69 6f 28 29 20 72 65 | 74 75 72 6e 73 20 61 20 |tio() re|turns a |
|00000e40| 66 6c 6f 61 74 20 69 6e | 20 5b 30 2c 20 31 5d 2c |float in| [0, 1],|
|00000e50| 20 6d 65 61 73 75 72 69 | 6e 67 20 74 68 65 20 22 | measuri|ng the "|
|00000e60| 73 69 6d 69 6c 61 72 69 | 74 79 22 20 6f 66 20 74 |similari|ty" of t|
|00000e70| 68 65 0a 20 20 20 20 73 | 65 71 75 65 6e 63 65 73 |he. s|equences|
|00000e80| 2e 20 20 41 73 20 61 20 | 72 75 6c 65 20 6f 66 20 |. As a |rule of |
|00000e90| 74 68 75 6d 62 2c 20 61 | 20 2e 72 61 74 69 6f 28 |thumb, a| .ratio(|
|00000ea0| 29 20 76 61 6c 75 65 20 | 6f 76 65 72 20 30 2e 36 |) value |over 0.6|
|00000eb0| 20 6d 65 61 6e 73 20 74 | 68 65 0a 20 20 20 20 73 | means t|he. s|
|00000ec0| 65 71 75 65 6e 63 65 73 | 20 61 72 65 20 63 6c 6f |equences| are clo|
|00000ed0| 73 65 20 6d 61 74 63 68 | 65 73 3a 0a 0a 20 20 20 |se match|es:.. |
|00000ee0| 20 3e 3e 3e 20 70 72 69 | 6e 74 20 72 6f 75 6e 64 | >>> pri|nt round|
|00000ef0| 28 73 2e 72 61 74 69 6f | 28 29 2c 20 33 29 0a 20 |(s.ratio|(), 3). |
|00000f00| 20 20 20 30 2e 38 36 36 | 0a 20 20 20 20 3e 3e 3e | 0.866|. >>>|
|00000f10| 0a 0a 20 20 20 20 49 66 | 20 79 6f 75 27 72 65 20 |.. If| you're |
|00000f20| 6f 6e 6c 79 20 69 6e 74 | 65 72 65 73 74 65 64 20 |only int|erested |
|00000f30| 69 6e 20 77 68 65 72 65 | 20 74 68 65 20 73 65 71 |in where| the seq|
|00000f40| 75 65 6e 63 65 73 20 6d | 61 74 63 68 2c 0a 20 20 |uences m|atch,. |
|00000f50| 20 20 2e 67 65 74 5f 6d | 61 74 63 68 69 6e 67 5f | .get_m|atching_|
|00000f60| 62 6c 6f 63 6b 73 28 29 | 20 69 73 20 68 61 6e 64 |blocks()| is hand|
|00000f70| 79 3a 0a 0a 20 20 20 20 | 3e 3e 3e 20 66 6f 72 20 |y:.. |>>> for |
|00000f80| 62 6c 6f 63 6b 20 69 6e | 20 73 2e 67 65 74 5f 6d |block in| s.get_m|
|00000f90| 61 74 63 68 69 6e 67 5f | 62 6c 6f 63 6b 73 28 29 |atching_|blocks()|
|00000fa0| 3a 0a 20 20 20 20 2e 2e | 2e 20 20 20 20 20 70 72 |:. ..|. pr|
|00000fb0| 69 6e 74 20 22 61 5b 25 | 64 5d 20 61 6e 64 20 62 |int "a[%|d] and b|
|00000fc0| 5b 25 64 5d 20 6d 61 74 | 63 68 20 66 6f 72 20 25 |[%d] mat|ch for %|
|00000fd0| 64 20 65 6c 65 6d 65 6e | 74 73 22 20 25 20 62 6c |d elemen|ts" % bl|
|00000fe0| 6f 63 6b 0a 20 20 20 20 | 61 5b 30 5d 20 61 6e 64 |ock. |a[0] and|
|00000ff0| 20 62 5b 30 5d 20 6d 61 | 74 63 68 20 66 6f 72 20 | b[0] ma|tch for |
|00001000| 38 20 65 6c 65 6d 65 6e | 74 73 0a 20 20 20 20 61 |8 elemen|ts. a|
|00001010| 5b 38 5d 20 61 6e 64 20 | 62 5b 31 37 5d 20 6d 61 |[8] and |b[17] ma|
|00001020| 74 63 68 20 66 6f 72 20 | 32 31 20 65 6c 65 6d 65 |tch for |21 eleme|
|00001030| 6e 74 73 0a 20 20 20 20 | 61 5b 32 39 5d 20 61 6e |nts. |a[29] an|
|00001040| 64 20 62 5b 33 38 5d 20 | 6d 61 74 63 68 20 66 6f |d b[38] |match fo|
|00001050| 72 20 30 20 65 6c 65 6d | 65 6e 74 73 0a 0a 20 20 |r 0 elem|ents.. |
|00001060| 20 20 4e 6f 74 65 20 74 | 68 61 74 20 74 68 65 20 | Note t|hat the |
|00001070| 6c 61 73 74 20 74 75 70 | 6c 65 20 72 65 74 75 72 |last tup|le retur|
|00001080| 6e 65 64 20 62 79 20 2e | 67 65 74 5f 6d 61 74 63 |ned by .|get_matc|
|00001090| 68 69 6e 67 5f 62 6c 6f | 63 6b 73 28 29 20 69 73 |hing_blo|cks() is|
|000010a0| 20 61 6c 77 61 79 73 20 | 61 0a 20 20 20 20 64 75 | always |a. du|
|000010b0| 6d 6d 79 2c 20 28 6c 65 | 6e 28 61 29 2c 20 6c 65 |mmy, (le|n(a), le|
|000010c0| 6e 28 62 29 2c 20 30 29 | 2c 20 61 6e 64 20 74 68 |n(b), 0)|, and th|
|000010d0| 69 73 20 69 73 20 74 68 | 65 20 6f 6e 6c 79 20 63 |is is th|e only c|
|000010e0| 61 73 65 20 69 6e 20 77 | 68 69 63 68 20 74 68 65 |ase in w|hich the|
|000010f0| 20 6c 61 73 74 0a 20 20 | 20 20 74 75 70 6c 65 20 | last. | tuple |
|00001100| 65 6c 65 6d 65 6e 74 20 | 28 6e 75 6d 62 65 72 20 |element |(number |
|00001110| 6f 66 20 65 6c 65 6d 65 | 6e 74 73 20 6d 61 74 63 |of eleme|nts matc|
|00001120| 68 65 64 29 20 69 73 20 | 30 2e 0a 0a 20 20 20 20 |hed) is |0... |
|00001130| 49 66 20 79 6f 75 20 77 | 61 6e 74 20 74 6f 20 6b |If you w|ant to k|
|00001140| 6e 6f 77 20 68 6f 77 20 | 74 6f 20 63 68 61 6e 67 |now how |to chang|
|00001150| 65 20 74 68 65 20 66 69 | 72 73 74 20 73 65 71 75 |e the fi|rst sequ|
|00001160| 65 6e 63 65 20 69 6e 74 | 6f 20 74 68 65 20 73 65 |ence int|o the se|
|00001170| 63 6f 6e 64 2c 0a 20 20 | 20 20 75 73 65 20 2e 67 |cond,. | use .g|
|00001180| 65 74 5f 6f 70 63 6f 64 | 65 73 28 29 3a 0a 0a 20 |et_opcod|es():.. |
|00001190| 20 20 20 3e 3e 3e 20 66 | 6f 72 20 6f 70 63 6f 64 | >>> f|or opcod|
|000011a0| 65 20 69 6e 20 73 2e 67 | 65 74 5f 6f 70 63 6f 64 |e in s.g|et_opcod|
|000011b0| 65 73 28 29 3a 0a 20 20 | 20 20 2e 2e 2e 20 20 20 |es():. | ... |
|000011c0| 20 20 70 72 69 6e 74 20 | 22 25 36 73 20 61 5b 25 | print |"%6s a[%|
|000011d0| 64 3a 25 64 5d 20 62 5b | 25 64 3a 25 64 5d 22 20 |d:%d] b[|%d:%d]" |
|000011e0| 25 20 6f 70 63 6f 64 65 | 0a 20 20 20 20 20 65 71 |% opcode|. eq|
|000011f0| 75 61 6c 20 61 5b 30 3a | 38 5d 20 62 5b 30 3a 38 |ual a[0:|8] b[0:8|
|00001200| 5d 0a 20 20 20 20 69 6e | 73 65 72 74 20 61 5b 38 |]. in|sert a[8|
|00001210| 3a 38 5d 20 62 5b 38 3a | 31 37 5d 0a 20 20 20 20 |:8] b[8:|17]. |
|00001220| 20 65 71 75 61 6c 20 61 | 5b 38 3a 32 39 5d 20 62 | equal a|[8:29] b|
|00001230| 5b 31 37 3a 33 38 5d 0a | 0a 20 20 20 20 53 65 65 |[17:38].|. See|
|00001240| 20 74 68 65 20 44 69 66 | 66 65 72 20 63 6c 61 73 | the Dif|fer clas|
|00001250| 73 20 66 6f 72 20 61 20 | 66 61 6e 63 79 20 68 75 |s for a |fancy hu|
|00001260| 6d 61 6e 2d 66 72 69 65 | 6e 64 6c 79 20 66 69 6c |man-frie|ndly fil|
|00001270| 65 20 64 69 66 66 65 72 | 65 6e 63 65 72 2c 20 77 |e differ|encer, w|
|00001280| 68 69 63 68 0a 20 20 20 | 20 75 73 65 73 20 53 65 |hich. | uses Se|
|00001290| 71 75 65 6e 63 65 4d 61 | 74 63 68 65 72 20 62 6f |quenceMa|tcher bo|
|000012a0| 74 68 20 74 6f 20 63 6f | 6d 70 61 72 65 20 73 65 |th to co|mpare se|
|000012b0| 71 75 65 6e 63 65 73 20 | 6f 66 20 6c 69 6e 65 73 |quences |of lines|
|000012c0| 2c 20 61 6e 64 20 74 6f | 20 63 6f 6d 70 61 72 65 |, and to| compare|
|000012d0| 0a 20 20 20 20 73 65 71 | 75 65 6e 63 65 73 20 6f |. seq|uences o|
|000012e0| 66 20 63 68 61 72 61 63 | 74 65 72 73 20 77 69 74 |f charac|ters wit|
|000012f0| 68 69 6e 20 73 69 6d 69 | 6c 61 72 20 28 6e 65 61 |hin simi|lar (nea|
|00001300| 72 2d 6d 61 74 63 68 69 | 6e 67 29 20 6c 69 6e 65 |r-matchi|ng) line|
|00001310| 73 2e 0a 0a 20 20 20 20 | 53 65 65 20 61 6c 73 6f |s... |See also|
|00001320| 20 66 75 6e 63 74 69 6f | 6e 20 67 65 74 5f 63 6c | functio|n get_cl|
|00001330| 6f 73 65 5f 6d 61 74 63 | 68 65 73 28 29 20 69 6e |ose_matc|hes() in|
|00001340| 20 74 68 69 73 20 6d 6f | 64 75 6c 65 2c 20 77 68 | this mo|dule, wh|
|00001350| 69 63 68 20 73 68 6f 77 | 73 20 68 6f 77 0a 20 20 |ich show|s how. |
|00001360| 20 20 73 69 6d 70 6c 65 | 20 63 6f 64 65 20 62 75 | simple| code bu|
|00001370| 69 6c 64 69 6e 67 20 6f | 6e 20 53 65 71 75 65 6e |ilding o|n Sequen|
|00001380| 63 65 4d 61 74 63 68 65 | 72 20 63 61 6e 20 62 65 |ceMatche|r can be|
|00001390| 20 75 73 65 64 20 74 6f | 20 64 6f 20 75 73 65 66 | used to| do usef|
|000013a0| 75 6c 20 77 6f 72 6b 2e | 0a 0a 20 20 20 20 54 69 |ul work.|.. Ti|
|000013b0| 6d 69 6e 67 3a 20 20 42 | 61 73 69 63 20 52 2d 4f |ming: B|asic R-O|
|000013c0| 20 69 73 20 63 75 62 69 | 63 20 74 69 6d 65 20 77 | is cubi|c time w|
|000013d0| 6f 72 73 74 20 63 61 73 | 65 20 61 6e 64 20 71 75 |orst cas|e and qu|
|000013e0| 61 64 72 61 74 69 63 20 | 74 69 6d 65 20 65 78 70 |adratic |time exp|
|000013f0| 65 63 74 65 64 0a 20 20 | 20 20 63 61 73 65 2e 20 |ected. | case. |
|00001400| 20 53 65 71 75 65 6e 63 | 65 4d 61 74 63 68 65 72 | Sequenc|eMatcher|
|00001410| 20 69 73 20 71 75 61 64 | 72 61 74 69 63 20 74 69 | is quad|ratic ti|
|00001420| 6d 65 20 66 6f 72 20 74 | 68 65 20 77 6f 72 73 74 |me for t|he worst|
|00001430| 20 63 61 73 65 20 61 6e | 64 20 68 61 73 0a 20 20 | case an|d has. |
|00001440| 20 20 65 78 70 65 63 74 | 65 64 2d 63 61 73 65 20 | expect|ed-case |
|00001450| 62 65 68 61 76 69 6f 72 | 20 64 65 70 65 6e 64 65 |behavior| depende|
|00001460| 6e 74 20 69 6e 20 61 20 | 63 6f 6d 70 6c 69 63 61 |nt in a |complica|
|00001470| 74 65 64 20 77 61 79 20 | 6f 6e 20 68 6f 77 20 6d |ted way |on how m|
|00001480| 61 6e 79 0a 20 20 20 20 | 65 6c 65 6d 65 6e 74 73 |any. |elements|
|00001490| 20 74 68 65 20 73 65 71 | 75 65 6e 63 65 73 20 68 | the seq|uences h|
|000014a0| 61 76 65 20 69 6e 20 63 | 6f 6d 6d 6f 6e 3b 20 62 |ave in c|ommon; b|
|000014b0| 65 73 74 20 63 61 73 65 | 20 74 69 6d 65 20 69 73 |est case| time is|
|000014c0| 20 6c 69 6e 65 61 72 2e | 0a 0a 20 20 20 20 4d 65 | linear.|.. Me|
|000014d0| 74 68 6f 64 73 3a 0a 0a | 20 20 20 20 5f 5f 69 6e |thods:..| __in|
|000014e0| 69 74 5f 5f 28 69 73 6a | 75 6e 6b 3d 4e 6f 6e 65 |it__(isj|unk=None|
|000014f0| 2c 20 61 3d 27 27 2c 20 | 62 3d 27 27 29 0a 20 20 |, a='', |b=''). |
|00001500| 20 20 20 20 20 20 43 6f | 6e 73 74 72 75 63 74 20 | Co|nstruct |
|00001510| 61 20 53 65 71 75 65 6e | 63 65 4d 61 74 63 68 65 |a Sequen|ceMatche|
|00001520| 72 2e 0a 0a 20 20 20 20 | 73 65 74 5f 73 65 71 73 |r... |set_seqs|
|00001530| 28 61 2c 20 62 29 0a 20 | 20 20 20 20 20 20 20 53 |(a, b). | S|
|00001540| 65 74 20 74 68 65 20 74 | 77 6f 20 73 65 71 75 65 |et the t|wo seque|
|00001550| 6e 63 65 73 20 74 6f 20 | 62 65 20 63 6f 6d 70 61 |nces to |be compa|
|00001560| 72 65 64 2e 0a 0a 20 20 | 20 20 73 65 74 5f 73 65 |red... | set_se|
|00001570| 71 31 28 61 29 0a 20 20 | 20 20 20 20 20 20 53 65 |q1(a). | Se|
|00001580| 74 20 74 68 65 20 66 69 | 72 73 74 20 73 65 71 75 |t the fi|rst sequ|
|00001590| 65 6e 63 65 20 74 6f 20 | 62 65 20 63 6f 6d 70 61 |ence to |be compa|
|000015a0| 72 65 64 2e 0a 0a 20 20 | 20 20 73 65 74 5f 73 65 |red... | set_se|
|000015b0| 71 32 28 62 29 0a 20 20 | 20 20 20 20 20 20 53 65 |q2(b). | Se|
|000015c0| 74 20 74 68 65 20 73 65 | 63 6f 6e 64 20 73 65 71 |t the se|cond seq|
|000015d0| 75 65 6e 63 65 20 74 6f | 20 62 65 20 63 6f 6d 70 |uence to| be comp|
|000015e0| 61 72 65 64 2e 0a 0a 20 | 20 20 20 66 69 6e 64 5f |ared... | find_|
|000015f0| 6c 6f 6e 67 65 73 74 5f | 6d 61 74 63 68 28 61 6c |longest_|match(al|
|00001600| 6f 2c 20 61 68 69 2c 20 | 62 6c 6f 2c 20 62 68 69 |o, ahi, |blo, bhi|
|00001610| 29 0a 20 20 20 20 20 20 | 20 20 46 69 6e 64 20 6c |). | Find l|
|00001620| 6f 6e 67 65 73 74 20 6d | 61 74 63 68 69 6e 67 20 |ongest m|atching |
|00001630| 62 6c 6f 63 6b 20 69 6e | 20 61 5b 61 6c 6f 3a 61 |block in| a[alo:a|
|00001640| 68 69 5d 20 61 6e 64 20 | 62 5b 62 6c 6f 3a 62 68 |hi] and |b[blo:bh|
|00001650| 69 5d 2e 0a 0a 20 20 20 | 20 67 65 74 5f 6d 61 74 |i]... | get_mat|
|00001660| 63 68 69 6e 67 5f 62 6c | 6f 63 6b 73 28 29 0a 20 |ching_bl|ocks(). |
|00001670| 20 20 20 20 20 20 20 52 | 65 74 75 72 6e 20 6c 69 | R|eturn li|
|00001680| 73 74 20 6f 66 20 74 72 | 69 70 6c 65 73 20 64 65 |st of tr|iples de|
|00001690| 73 63 72 69 62 69 6e 67 | 20 6d 61 74 63 68 69 6e |scribing| matchin|
|000016a0| 67 20 73 75 62 73 65 71 | 75 65 6e 63 65 73 2e 0a |g subseq|uences..|
|000016b0| 0a 20 20 20 20 67 65 74 | 5f 6f 70 63 6f 64 65 73 |. get|_opcodes|
|000016c0| 28 29 0a 20 20 20 20 20 | 20 20 20 52 65 74 75 72 |(). | Retur|
|000016d0| 6e 20 6c 69 73 74 20 6f | 66 20 35 2d 74 75 70 6c |n list o|f 5-tupl|
|000016e0| 65 73 20 64 65 73 63 72 | 69 62 69 6e 67 20 68 6f |es descr|ibing ho|
|000016f0| 77 20 74 6f 20 74 75 72 | 6e 20 61 20 69 6e 74 6f |w to tur|n a into|
|00001700| 20 62 2e 0a 0a 20 20 20 | 20 72 61 74 69 6f 28 29 | b... | ratio()|
|00001710| 0a 20 20 20 20 20 20 20 | 20 52 65 74 75 72 6e 20 |. | Return |
|00001720| 61 20 6d 65 61 73 75 72 | 65 20 6f 66 20 74 68 65 |a measur|e of the|
|00001730| 20 73 65 71 75 65 6e 63 | 65 73 27 20 73 69 6d 69 | sequenc|es' simi|
|00001740| 6c 61 72 69 74 79 20 28 | 66 6c 6f 61 74 20 69 6e |larity (|float in|
|00001750| 20 5b 30 2c 31 5d 29 2e | 0a 0a 20 20 20 20 71 75 | [0,1]).|.. qu|
|00001760| 69 63 6b 5f 72 61 74 69 | 6f 28 29 0a 20 20 20 20 |ick_rati|o(). |
|00001770| 20 20 20 20 52 65 74 75 | 72 6e 20 61 6e 20 75 70 | Retu|rn an up|
|00001780| 70 65 72 20 62 6f 75 6e | 64 20 6f 6e 20 2e 72 61 |per boun|d on .ra|
|00001790| 74 69 6f 28 29 20 72 65 | 6c 61 74 69 76 65 6c 79 |tio() re|latively|
|000017a0| 20 71 75 69 63 6b 6c 79 | 2e 0a 0a 20 20 20 20 72 | quickly|... r|
|000017b0| 65 61 6c 5f 71 75 69 63 | 6b 5f 72 61 74 69 6f 28 |eal_quic|k_ratio(|
|000017c0| 29 0a 20 20 20 20 20 20 | 20 20 52 65 74 75 72 6e |). | Return|
|000017d0| 20 61 6e 20 75 70 70 65 | 72 20 62 6f 75 6e 64 20 | an uppe|r bound |
|000017e0| 6f 6e 20 72 61 74 69 6f | 28 29 20 76 65 72 79 20 |on ratio|() very |
|000017f0| 71 75 69 63 6b 6c 79 2e | 0a 20 20 20 20 74 00 00 |quickly.|. t..|
|00001800| 00 00 63 05 00 00 00 05 | 00 00 00 03 00 00 00 43 |..c.....|.......C|
|00001810| 00 00 00 73 36 00 00 00 | 7c 01 00 7c 00 00 5f 00 |...s6...||..|.._.|
|00001820| 00 64 01 00 04 7c 00 00 | 5f 02 00 7c 00 00 5f 03 |.d...|..|_..|.._.|
|00001830| 00 7c 04 00 7c 00 00 5f | 04 00 7c 00 00 6a 05 00 |.|..|.._|..|..j..|
|00001840| 7c 02 00 7c 03 00 83 02 | 00 01 64 01 00 53 28 02 ||..|....|..d..S(.|
|00001850| 00 00 00 73 21 04 00 00 | 43 6f 6e 73 74 72 75 63 |...s!...|Construc|
|00001860| 74 20 61 20 53 65 71 75 | 65 6e 63 65 4d 61 74 63 |t a Sequ|enceMatc|
|00001870| 68 65 72 2e 0a 0a 20 20 | 20 20 20 20 20 20 4f 70 |her... | Op|
|00001880| 74 69 6f 6e 61 6c 20 61 | 72 67 20 69 73 6a 75 6e |tional a|rg isjun|
|00001890| 6b 20 69 73 20 4e 6f 6e | 65 20 28 74 68 65 20 64 |k is Non|e (the d|
|000018a0| 65 66 61 75 6c 74 29 2c | 20 6f 72 20 61 20 6f 6e |efault),| or a on|
|000018b0| 65 2d 61 72 67 75 6d 65 | 6e 74 0a 20 20 20 20 20 |e-argume|nt. |
|000018c0| 20 20 20 66 75 6e 63 74 | 69 6f 6e 20 74 68 61 74 | funct|ion that|
|000018d0| 20 74 61 6b 65 73 20 61 | 20 73 65 71 75 65 6e 63 | takes a| sequenc|
|000018e0| 65 20 65 6c 65 6d 65 6e | 74 20 61 6e 64 20 72 65 |e elemen|t and re|
|000018f0| 74 75 72 6e 73 20 74 72 | 75 65 20 69 66 66 20 74 |turns tr|ue iff t|
|00001900| 68 65 0a 20 20 20 20 20 | 20 20 20 65 6c 65 6d 65 |he. | eleme|
|00001910| 6e 74 20 69 73 20 6a 75 | 6e 6b 2e 20 20 4e 6f 6e |nt is ju|nk. Non|
|00001920| 65 20 69 73 20 65 71 75 | 69 76 61 6c 65 6e 74 20 |e is equ|ivalent |
|00001930| 74 6f 20 70 61 73 73 69 | 6e 67 20 22 6c 61 6d 62 |to passi|ng "lamb|
|00001940| 64 61 20 78 3a 20 30 22 | 2c 20 69 2e 65 2e 0a 20 |da x: 0"|, i.e.. |
|00001950| 20 20 20 20 20 20 20 6e | 6f 20 65 6c 65 6d 65 6e | n|o elemen|
|00001960| 74 73 20 61 72 65 20 63 | 6f 6e 73 69 64 65 72 65 |ts are c|onsidere|
|00001970| 64 20 74 6f 20 62 65 20 | 6a 75 6e 6b 2e 20 20 46 |d to be |junk. F|
|00001980| 6f 72 20 65 78 61 6d 70 | 6c 65 2c 20 70 61 73 73 |or examp|le, pass|
|00001990| 0a 20 20 20 20 20 20 20 | 20 20 20 20 20 6c 61 6d |. | lam|
|000019a0| 62 64 61 20 78 3a 20 78 | 20 69 6e 20 22 20 5c 74 |bda x: x| in " \t|
|000019b0| 22 0a 20 20 20 20 20 20 | 20 20 69 66 20 79 6f 75 |". | if you|
|000019c0| 27 72 65 20 63 6f 6d 70 | 61 72 69 6e 67 20 6c 69 |'re comp|aring li|
|000019d0| 6e 65 73 20 61 73 20 73 | 65 71 75 65 6e 63 65 73 |nes as s|equences|
|000019e0| 20 6f 66 20 63 68 61 72 | 61 63 74 65 72 73 2c 20 | of char|acters, |
|000019f0| 61 6e 64 20 64 6f 6e 27 | 74 0a 20 20 20 20 20 20 |and don'|t. |
|00001a00| 20 20 77 61 6e 74 20 74 | 6f 20 73 79 6e 63 68 20 | want t|o synch |
|00001a10| 75 70 20 6f 6e 20 62 6c | 61 6e 6b 73 20 6f 72 20 |up on bl|anks or |
|00001a20| 68 61 72 64 20 74 61 62 | 73 2e 0a 0a 20 20 20 20 |hard tab|s... |
|00001a30| 20 20 20 20 4f 70 74 69 | 6f 6e 61 6c 20 61 72 67 | Opti|onal arg|
|00001a40| 20 61 20 69 73 20 74 68 | 65 20 66 69 72 73 74 20 | a is th|e first |
|00001a50| 6f 66 20 74 77 6f 20 73 | 65 71 75 65 6e 63 65 73 |of two s|equences|
|00001a60| 20 74 6f 20 62 65 20 63 | 6f 6d 70 61 72 65 64 2e | to be c|ompared.|
|00001a70| 20 20 42 79 0a 20 20 20 | 20 20 20 20 20 64 65 66 | By. | def|
|00001a80| 61 75 6c 74 2c 20 61 6e | 20 65 6d 70 74 79 20 73 |ault, an| empty s|
|00001a90| 74 72 69 6e 67 2e 20 20 | 54 68 65 20 65 6c 65 6d |tring. |The elem|
|00001aa0| 65 6e 74 73 20 6f 66 20 | 61 20 6d 75 73 74 20 62 |ents of |a must b|
|00001ab0| 65 20 68 61 73 68 61 62 | 6c 65 2e 20 20 53 65 65 |e hashab|le. See|
|00001ac0| 0a 20 20 20 20 20 20 20 | 20 61 6c 73 6f 20 2e 73 |. | also .s|
|00001ad0| 65 74 5f 73 65 71 73 28 | 29 20 61 6e 64 20 2e 73 |et_seqs(|) and .s|
|00001ae0| 65 74 5f 73 65 71 31 28 | 29 2e 0a 0a 20 20 20 20 |et_seq1(|)... |
|00001af0| 20 20 20 20 4f 70 74 69 | 6f 6e 61 6c 20 61 72 67 | Opti|onal arg|
|00001b00| 20 62 20 69 73 20 74 68 | 65 20 73 65 63 6f 6e 64 | b is th|e second|
|00001b10| 20 6f 66 20 74 77 6f 20 | 73 65 71 75 65 6e 63 65 | of two |sequence|
|00001b20| 73 20 74 6f 20 62 65 20 | 63 6f 6d 70 61 72 65 64 |s to be |compared|
|00001b30| 2e 20 20 42 79 0a 20 20 | 20 20 20 20 20 20 64 65 |. By. | de|
|00001b40| 66 61 75 6c 74 2c 20 61 | 6e 20 65 6d 70 74 79 20 |fault, a|n empty |
|00001b50| 73 74 72 69 6e 67 2e 20 | 20 54 68 65 20 65 6c 65 |string. | The ele|
|00001b60| 6d 65 6e 74 73 20 6f 66 | 20 62 20 6d 75 73 74 20 |ments of| b must |
|00001b70| 62 65 20 68 61 73 68 61 | 62 6c 65 2e 20 53 65 65 |be hasha|ble. See|
|00001b80| 0a 20 20 20 20 20 20 20 | 20 61 6c 73 6f 20 2e 73 |. | also .s|
|00001b90| 65 74 5f 73 65 71 73 28 | 29 20 61 6e 64 20 2e 73 |et_seqs(|) and .s|
|00001ba0| 65 74 5f 73 65 71 32 28 | 29 2e 0a 0a 20 20 20 20 |et_seq2(|)... |
|00001bb0| 20 20 20 20 4f 70 74 69 | 6f 6e 61 6c 20 61 72 67 | Opti|onal arg|
|00001bc0| 20 61 75 74 6f 6a 75 6e | 6b 20 73 68 6f 75 6c 64 | autojun|k should|
|00001bd0| 20 62 65 20 73 65 74 20 | 74 6f 20 46 61 6c 73 65 | be set |to False|
|00001be0| 20 74 6f 20 64 69 73 61 | 62 6c 65 20 74 68 65 0a | to disa|ble the.|
|00001bf0| 20 20 20 20 20 20 20 20 | 22 61 75 74 6f 6d 61 74 | |"automat|
|00001c00| 69 63 20 6a 75 6e 6b 20 | 68 65 75 72 69 73 74 69 |ic junk |heuristi|
|00001c10| 63 22 20 74 68 61 74 20 | 74 72 65 61 74 73 20 70 |c" that |treats p|
|00001c20| 6f 70 75 6c 61 72 20 65 | 6c 65 6d 65 6e 74 73 20 |opular e|lements |
|00001c30| 61 73 20 6a 75 6e 6b 0a | 20 20 20 20 20 20 20 20 |as junk.| |
|00001c40| 28 73 65 65 20 6d 6f 64 | 75 6c 65 20 64 6f 63 75 |(see mod|ule docu|
|00001c50| 6d 65 6e 74 61 74 69 6f | 6e 20 66 6f 72 20 6d 6f |mentatio|n for mo|
|00001c60| 72 65 20 69 6e 66 6f 72 | 6d 61 74 69 6f 6e 29 2e |re infor|mation).|
|00001c70| 0a 20 20 20 20 20 20 20 | 20 4e 28 06 00 00 00 74 |. | N(....t|
|00001c80| 06 00 00 00 69 73 6a 75 | 6e 6b 74 04 00 00 00 4e |....isju|nkt....N|
|00001c90| 6f 6e 65 74 01 00 00 00 | 61 74 01 00 00 00 62 74 |onet....|at....bt|
|00001ca0| 08 00 00 00 61 75 74 6f | 6a 75 6e 6b 74 08 00 00 |....auto|junkt...|
|00001cb0| 00 73 65 74 5f 73 65 71 | 73 28 05 00 00 00 74 04 |.set_seq|s(....t.|
|00001cc0| 00 00 00 73 65 6c 66 52 | 11 00 00 00 52 13 00 00 |...selfR|....R...|
|00001cd0| 00 52 14 00 00 00 52 15 | 00 00 00 28 00 00 00 00 |.R....R.|...(....|
|00001ce0| 28 00 00 00 00 73 0b 00 | 00 00 64 69 66 66 6c 69 |(....s..|..diffli|
|00001cf0| 62 2e 70 79 63 74 08 00 | 00 00 5f 5f 69 6e 69 74 |b.pyct..|..__init|
|00001d00| 5f 5f 9a 00 00 00 73 08 | 00 00 00 00 40 09 01 10 |__....s.|....@...|
|00001d10| 01 09 01 63 03 00 00 00 | 03 00 00 00 02 00 00 00 |...c....|........|
|00001d20| 43 00 00 00 73 1e 00 00 | 00 7c 00 00 6a 00 00 7c |C...s...|.|..j..||
|00001d30| 01 00 83 01 00 01 7c 00 | 00 6a 01 00 7c 02 00 83 |......|.|.j..|...|
|00001d40| 01 00 01 64 01 00 53 28 | 02 00 00 00 73 9b 00 00 |...d..S(|....s...|
|00001d50| 00 53 65 74 20 74 68 65 | 20 74 77 6f 20 73 65 71 |.Set the| two seq|
|00001d60| 75 65 6e 63 65 73 20 74 | 6f 20 62 65 20 63 6f 6d |uences t|o be com|
|00001d70| 70 61 72 65 64 2e 0a 0a | 20 20 20 20 20 20 20 20 |pared...| |
|00001d80| 3e 3e 3e 20 73 20 3d 20 | 53 65 71 75 65 6e 63 65 |>>> s = |Sequence|
|00001d90| 4d 61 74 63 68 65 72 28 | 29 0a 20 20 20 20 20 20 |Matcher(|). |
|00001da0| 20 20 3e 3e 3e 20 73 2e | 73 65 74 5f 73 65 71 73 | >>> s.|set_seqs|
|00001db0| 28 22 61 62 63 64 22 2c | 20 22 62 63 64 65 22 29 |("abcd",| "bcde")|
|00001dc0| 0a 20 20 20 20 20 20 20 | 20 3e 3e 3e 20 73 2e 72 |. | >>> s.r|
|00001dd0| 61 74 69 6f 28 29 0a 20 | 20 20 20 20 20 20 20 30 |atio(). | 0|
|00001de0| 2e 37 35 0a 20 20 20 20 | 20 20 20 20 4e 28 02 00 |.75. | N(..|
|00001df0| 00 00 74 08 00 00 00 73 | 65 74 5f 73 65 71 31 74 |..t....s|et_seq1t|
|00001e00| 08 00 00 00 73 65 74 5f | 73 65 71 32 28 03 00 00 |....set_|seq2(...|
|00001e10| 00 52 17 00 00 00 52 13 | 00 00 00 52 14 00 00 00 |.R....R.|...R....|
|00001e20| 28 00 00 00 00 28 00 00 | 00 00 73 0b 00 00 00 64 |(....(..|..s....d|
|00001e30| 69 66 66 6c 69 62 2e 70 | 79 63 52 16 00 00 00 df |ifflib.p|ycR.....|
|00001e40| 00 00 00 73 04 00 00 00 | 00 09 0d 01 63 02 00 00 |...s....|....c...|
|00001e50| 00 02 00 00 00 03 00 00 | 00 43 00 00 00 73 30 00 |........|.C...s0.|
|00001e60| 00 00 7c 01 00 7c 00 00 | 6a 00 00 6b 08 00 72 13 |..|..|..|j..k..r.|
|00001e70| 00 64 01 00 53 7c 01 00 | 7c 00 00 5f 00 00 64 01 |.d..S|..||.._..d.|
|00001e80| 00 04 7c 00 00 5f 02 00 | 7c 00 00 5f 03 00 64 01 |..|.._..||.._..d.|
|00001e90| 00 53 28 02 00 00 00 73 | 4d 02 00 00 53 65 74 20 |.S(....s|M...Set |
|00001ea0| 74 68 65 20 66 69 72 73 | 74 20 73 65 71 75 65 6e |the firs|t sequen|
|00001eb0| 63 65 20 74 6f 20 62 65 | 20 63 6f 6d 70 61 72 65 |ce to be| compare|
|00001ec0| 64 2e 0a 0a 20 20 20 20 | 20 20 20 20 54 68 65 20 |d... | The |
|00001ed0| 73 65 63 6f 6e 64 20 73 | 65 71 75 65 6e 63 65 20 |second s|equence |
|00001ee0| 74 6f 20 62 65 20 63 6f | 6d 70 61 72 65 64 20 69 |to be co|mpared i|
|00001ef0| 73 20 6e 6f 74 20 63 68 | 61 6e 67 65 64 2e 0a 0a |s not ch|anged...|
|00001f00| 20 20 20 20 20 20 20 20 | 3e 3e 3e 20 73 20 3d 20 | |>>> s = |
|00001f10| 53 65 71 75 65 6e 63 65 | 4d 61 74 63 68 65 72 28 |Sequence|Matcher(|
|00001f20| 4e 6f 6e 65 2c 20 22 61 | 62 63 64 22 2c 20 22 62 |None, "a|bcd", "b|
|00001f30| 63 64 65 22 29 0a 20 20 | 20 20 20 20 20 20 3e 3e |cde"). | >>|
|00001f40| 3e 20 73 2e 72 61 74 69 | 6f 28 29 0a 20 20 20 20 |> s.rati|o(). |
|00001f50| 20 20 20 20 30 2e 37 35 | 0a 20 20 20 20 20 20 20 | 0.75|. |
|00001f60| 20 3e 3e 3e 20 73 2e 73 | 65 74 5f 73 65 71 31 28 | >>> s.s|et_seq1(|
|00001f70| 22 62 63 64 65 22 29 0a | 20 20 20 20 20 20 20 20 |"bcde").| |
|00001f80| 3e 3e 3e 20 73 2e 72 61 | 74 69 6f 28 29 0a 20 20 |>>> s.ra|tio(). |
|00001f90| 20 20 20 20 20 20 31 2e | 30 0a 20 20 20 20 20 20 | 1.|0. |
|00001fa0| 20 20 3e 3e 3e 0a 0a 20 | 20 20 20 20 20 20 20 53 | >>>.. | S|
|00001fb0| 65 71 75 65 6e 63 65 4d | 61 74 63 68 65 72 20 63 |equenceM|atcher c|
|00001fc0| 6f 6d 70 75 74 65 73 20 | 61 6e 64 20 63 61 63 68 |omputes |and cach|
|00001fd0| 65 73 20 64 65 74 61 69 | 6c 65 64 20 69 6e 66 6f |es detai|led info|
|00001fe0| 72 6d 61 74 69 6f 6e 20 | 61 62 6f 75 74 20 74 68 |rmation |about th|
|00001ff0| 65 0a 20 20 20 20 20 20 | 20 20 73 65 63 6f 6e 64 |e. | second|
|00002000| 20 73 65 71 75 65 6e 63 | 65 2c 20 73 6f 20 69 66 | sequenc|e, so if|
|00002010| 20 79 6f 75 20 77 61 6e | 74 20 74 6f 20 63 6f 6d | you wan|t to com|
|00002020| 70 61 72 65 20 6f 6e 65 | 20 73 65 71 75 65 6e 63 |pare one| sequenc|
|00002030| 65 20 53 20 61 67 61 69 | 6e 73 74 0a 20 20 20 20 |e S agai|nst. |
|00002040| 20 20 20 20 6d 61 6e 79 | 20 73 65 71 75 65 6e 63 | many| sequenc|
|00002050| 65 73 2c 20 75 73 65 20 | 2e 73 65 74 5f 73 65 71 |es, use |.set_seq|
|00002060| 32 28 53 29 20 6f 6e 63 | 65 20 61 6e 64 20 63 61 |2(S) onc|e and ca|
|00002070| 6c 6c 20 2e 73 65 74 5f | 73 65 71 31 28 78 29 0a |ll .set_|seq1(x).|
|00002080| 20 20 20 20 20 20 20 20 | 72 65 70 65 61 74 65 64 | |repeated|
|00002090| 6c 79 20 66 6f 72 20 65 | 61 63 68 20 6f 66 20 74 |ly for e|ach of t|
|000020a0| 68 65 20 6f 74 68 65 72 | 20 73 65 71 75 65 6e 63 |he other| sequenc|
|000020b0| 65 73 2e 0a 0a 20 20 20 | 20 20 20 20 20 53 65 65 |es... | See|
|000020c0| 20 61 6c 73 6f 20 73 65 | 74 5f 73 65 71 73 28 29 | also se|t_seqs()|
|000020d0| 20 61 6e 64 20 73 65 74 | 5f 73 65 71 32 28 29 2e | and set|_seq2().|
|000020e0| 0a 20 20 20 20 20 20 20 | 20 4e 28 04 00 00 00 52 |. | N(....R|
|000020f0| 13 00 00 00 52 12 00 00 | 00 74 0f 00 00 00 6d 61 |....R...|.t....ma|
|00002100| 74 63 68 69 6e 67 5f 62 | 6c 6f 63 6b 73 74 07 00 |tching_b|lockst..|
|00002110| 00 00 6f 70 63 6f 64 65 | 73 28 02 00 00 00 52 17 |..opcode|s(....R.|
|00002120| 00 00 00 52 13 00 00 00 | 28 00 00 00 00 28 00 00 |...R....|(....(..|
|00002130| 00 00 73 0b 00 00 00 64 | 69 66 66 6c 69 62 2e 70 |..s....d|ifflib.p|
|00002140| 79 63 52 19 00 00 00 eb | 00 00 00 73 08 00 00 00 |ycR.....|...s....|
|00002150| 00 15 0f 01 04 01 09 01 | 63 02 00 00 00 02 00 00 |........|c.......|
|00002160| 00 03 00 00 00 43 00 00 | 00 73 43 00 00 00 7c 01 |.....C..|.sC...|.|
|00002170| 00 7c 00 00 6a 00 00 6b | 08 00 72 13 00 64 01 00 |.|..j..k|..r..d..|
|00002180| 53 7c 01 00 7c 00 00 5f | 00 00 64 01 00 04 7c 00 |S|..|.._|..d...|.|
|00002190| 00 5f 02 00 7c 00 00 5f | 03 00 64 01 00 7c 00 00 |._..|.._|..d..|..|
|000021a0| 5f 04 00 7c 00 00 6a 05 | 00 83 00 00 01 64 01 00 |_..|..j.|.....d..|
|000021b0| 53 28 02 00 00 00 73 4d | 02 00 00 53 65 74 20 74 |S(....sM|...Set t|
|000021c0| 68 65 20 73 65 63 6f 6e | 64 20 73 65 71 75 65 6e |he secon|d sequen|
|000021d0| 63 65 20 74 6f 20 62 65 | 20 63 6f 6d 70 61 72 65 |ce to be| compare|
|000021e0| 64 2e 0a 0a 20 20 20 20 | 20 20 20 20 54 68 65 20 |d... | The |
|000021f0| 66 69 72 73 74 20 73 65 | 71 75 65 6e 63 65 20 74 |first se|quence t|
|00002200| 6f 20 62 65 20 63 6f 6d | 70 61 72 65 64 20 69 73 |o be com|pared is|
|00002210| 20 6e 6f 74 20 63 68 61 | 6e 67 65 64 2e 0a 0a 20 | not cha|nged... |
|00002220| 20 20 20 20 20 20 20 3e | 3e 3e 20 73 20 3d 20 53 | >|>> s = S|
|00002230| 65 71 75 65 6e 63 65 4d | 61 74 63 68 65 72 28 4e |equenceM|atcher(N|
|00002240| 6f 6e 65 2c 20 22 61 62 | 63 64 22 2c 20 22 62 63 |one, "ab|cd", "bc|
|00002250| 64 65 22 29 0a 20 20 20 | 20 20 20 20 20 3e 3e 3e |de"). | >>>|
|00002260| 20 73 2e 72 61 74 69 6f | 28 29 0a 20 20 20 20 20 | s.ratio|(). |
|00002270| 20 20 20 30 2e 37 35 0a | 20 20 20 20 20 20 20 20 | 0.75.| |
|00002280| 3e 3e 3e 20 73 2e 73 65 | 74 5f 73 65 71 32 28 22 |>>> s.se|t_seq2("|
|00002290| 61 62 63 64 22 29 0a 20 | 20 20 20 20 20 20 20 3e |abcd"). | >|
|000022a0| 3e 3e 20 73 2e 72 61 74 | 69 6f 28 29 0a 20 20 20 |>> s.rat|io(). |
|000022b0| 20 20 20 20 20 31 2e 30 | 0a 20 20 20 20 20 20 20 | 1.0|. |
|000022c0| 20 3e 3e 3e 0a 0a 20 20 | 20 20 20 20 20 20 53 65 | >>>.. | Se|
|000022d0| 71 75 65 6e 63 65 4d 61 | 74 63 68 65 72 20 63 6f |quenceMa|tcher co|
|000022e0| 6d 70 75 74 65 73 20 61 | 6e 64 20 63 61 63 68 65 |mputes a|nd cache|
|000022f0| 73 20 64 65 74 61 69 6c | 65 64 20 69 6e 66 6f 72 |s detail|ed infor|
|00002300| 6d 61 74 69 6f 6e 20 61 | 62 6f 75 74 20 74 68 65 |mation a|bout the|
|00002310| 0a 20 20 20 20 20 20 20 | 20 73 65 63 6f 6e 64 20 |. | second |
|00002320| 73 65 71 75 65 6e 63 65 | 2c 20 73 6f 20 69 66 20 |sequence|, so if |
|00002330| 79 6f 75 20 77 61 6e 74 | 20 74 6f 20 63 6f 6d 70 |you want| to comp|
|00002340| 61 72 65 20 6f 6e 65 20 | 73 65 71 75 65 6e 63 65 |are one |sequence|
|00002350| 20 53 20 61 67 61 69 6e | 73 74 0a 20 20 20 20 20 | S again|st. |
|00002360| 20 20 20 6d 61 6e 79 20 | 73 65 71 75 65 6e 63 65 | many |sequence|
|00002370| 73 2c 20 75 73 65 20 2e | 73 65 74 5f 73 65 71 32 |s, use .|set_seq2|
|00002380| 28 53 29 20 6f 6e 63 65 | 20 61 6e 64 20 63 61 6c |(S) once| and cal|
|00002390| 6c 20 2e 73 65 74 5f 73 | 65 71 31 28 78 29 0a 20 |l .set_s|eq1(x). |
|000023a0| 20 20 20 20 20 20 20 72 | 65 70 65 61 74 65 64 6c | r|epeatedl|
|000023b0| 79 20 66 6f 72 20 65 61 | 63 68 20 6f 66 20 74 68 |y for ea|ch of th|
|000023c0| 65 20 6f 74 68 65 72 20 | 73 65 71 75 65 6e 63 65 |e other |sequence|
|000023d0| 73 2e 0a 0a 20 20 20 20 | 20 20 20 20 53 65 65 20 |s... | See |
|000023e0| 61 6c 73 6f 20 73 65 74 | 5f 73 65 71 73 28 29 20 |also set|_seqs() |
|000023f0| 61 6e 64 20 73 65 74 5f | 73 65 71 31 28 29 2e 0a |and set_|seq1()..|
|00002400| 20 20 20 20 20 20 20 20 | 4e 28 06 00 00 00 52 14 | |N(....R.|
|00002410| 00 00 00 52 12 00 00 00 | 52 1b 00 00 00 52 1c 00 |...R....|R....R..|
|00002420| 00 00 74 0a 00 00 00 66 | 75 6c 6c 62 63 6f 75 6e |..t....f|ullbcoun|
|00002430| 74 74 19 00 00 00 5f 53 | 65 71 75 65 6e 63 65 4d |tt...._S|equenceM|
|00002440| 61 74 63 68 65 72 5f 5f | 63 68 61 69 6e 5f 62 28 |atcher__|chain_b(|
|00002450| 02 00 00 00 52 17 00 00 | 00 52 14 00 00 00 28 00 |....R...|.R....(.|
|00002460| 00 00 00 28 00 00 00 00 | 73 0b 00 00 00 64 69 66 |...(....|s....dif|
|00002470| 66 6c 69 62 2e 70 79 63 | 52 1a 00 00 00 05 01 00 |flib.pyc|R.......|
|00002480| 00 73 0c 00 00 00 00 15 | 0f 01 04 01 09 01 10 01 |.s......|........|
|00002490| 09 01 63 01 00 00 00 0c | 00 00 00 04 00 00 00 43 |..c.....|.......C|
|000024a0| 00 00 00 73 50 01 00 00 | 7c 00 00 6a 00 00 7d 01 |...sP...||..j..}.|
|000024b0| 00 69 00 00 04 7c 00 00 | 5f 01 00 7d 02 00 78 39 |.i...|..|_..}..x9|
|000024c0| 00 74 02 00 7c 01 00 83 | 01 00 44 5d 2b 00 5c 02 |.t..|...|..D]+.\.|
|000024d0| 00 7d 03 00 7d 04 00 7c | 02 00 6a 03 00 7c 04 00 |.}..}..||..j..|..|
|000024e0| 67 00 00 83 02 00 7d 05 | 00 7c 05 00 6a 04 00 7c |g.....}.|.|..j..||
|000024f0| 03 00 83 01 00 01 71 23 | 00 57 74 05 00 83 00 00 |......q#|.Wt.....|
|00002500| 7d 06 00 7c 00 00 6a 06 | 00 7d 07 00 7c 07 00 72 |}..|..j.|.}..|..r|
|00002510| ad 00 78 40 00 74 07 00 | 7c 02 00 6a 08 00 83 00 |..x@.t..||..j....|
|00002520| 00 83 01 00 44 5d 29 00 | 7d 04 00 7c 07 00 7c 04 |....D]).|}..|..|.|
|00002530| 00 83 01 00 72 7d 00 7c | 06 00 6a 09 00 7c 04 00 |....r}.||..j..|..|
|00002540| 83 01 00 01 7c 02 00 7c | 04 00 3d 71 7d 00 71 7d |....|..||..=q}.q}|
|00002550| 00 57 6e 00 00 74 05 00 | 83 00 00 7d 08 00 74 0a |.Wn..t..|...}..t.|
|00002560| 00 7c 01 00 83 01 00 7d | 09 00 7c 00 00 6a 0b 00 |.|.....}|..|..j..|
|00002570| 72 34 01 7c 09 00 64 01 | 00 6b 05 00 72 34 01 7c |r4.|..d.|.k..r4.||
|00002580| 09 00 64 02 00 1a 64 03 | 00 17 7d 0a 00 78 4c 00 |..d...d.|..}..xL.|
|00002590| 74 07 00 7c 02 00 6a 0c | 00 83 00 00 83 01 00 44 |t..|..j.|.......D|
|000025a0| 5d 35 00 5c 02 00 7d 04 | 00 7d 0b 00 74 0a 00 7c |]5.\..}.|.}..t..||
|000025b0| 0b 00 83 01 00 7c 0a 00 | 6b 04 00 72 f8 00 7c 08 |.....|..|k..r..|.|
|000025c0| 00 6a 09 00 7c 04 00 83 | 01 00 01 7c 02 00 7c 04 |.j..|...|...|..|.|
|000025d0| 00 3d 71 f8 00 71 f8 00 | 57 6e 00 00 7c 06 00 6a |.=q..q..|Wn..|..j|
|000025e0| 0d 00 7c 00 00 5f 0e 00 | 7c 08 00 6a 0d 00 7c 00 |..|.._..||..j..|.|
|000025f0| 00 5f 0f 00 64 00 00 53 | 28 04 00 00 00 4e 69 c8 |._..d..S|(....Ni.|
|00002600| 00 00 00 69 64 00 00 00 | 69 01 00 00 00 28 10 00 |...id...|i....(..|
|00002610| 00 00 52 14 00 00 00 74 | 03 00 00 00 62 32 6a 74 |..R....t|....b2jt|
|00002620| 09 00 00 00 65 6e 75 6d | 65 72 61 74 65 74 0a 00 |....enum|eratet..|
|00002630| 00 00 73 65 74 64 65 66 | 61 75 6c 74 74 06 00 00 |..setdef|aultt...|
|00002640| 00 61 70 70 65 6e 64 74 | 03 00 00 00 73 65 74 52 |.appendt|....setR|
|00002650| 11 00 00 00 74 04 00 00 | 00 6c 69 73 74 74 04 00 |....t...|.listt..|
|00002660| 00 00 6b 65 79 73 74 03 | 00 00 00 61 64 64 74 03 |..keyst.|...addt.|
|00002670| 00 00 00 6c 65 6e 52 15 | 00 00 00 74 05 00 00 00 |...lenR.|...t....|
|00002680| 69 74 65 6d 73 74 0c 00 | 00 00 5f 5f 63 6f 6e 74 |itemst..|..__cont|
|00002690| 61 69 6e 73 5f 5f 74 07 | 00 00 00 69 73 62 6a 75 |ains__t.|...isbju|
|000026a0| 6e 6b 74 0a 00 00 00 69 | 73 62 70 6f 70 75 6c 61 |nkt....i|sbpopula|
|000026b0| 72 28 0c 00 00 00 52 17 | 00 00 00 52 14 00 00 00 |r(....R.|...R....|
|000026c0| 52 1f 00 00 00 74 01 00 | 00 00 69 74 03 00 00 00 |R....t..|..it....|
|000026d0| 65 6c 74 74 07 00 00 00 | 69 6e 64 69 63 65 73 74 |eltt....|indicest|
|000026e0| 04 00 00 00 6a 75 6e 6b | 52 11 00 00 00 74 07 00 |....junk|R....t..|
|000026f0| 00 00 70 6f 70 75 6c 61 | 72 74 01 00 00 00 6e 74 |..popula|rt....nt|
|00002700| 05 00 00 00 6e 74 65 73 | 74 74 04 00 00 00 69 64 |....ntes|tt....id|
|00002710| 78 73 28 00 00 00 00 28 | 00 00 00 00 73 0b 00 00 |xs(....(|....s...|
|00002720| 00 64 69 66 66 6c 69 62 | 2e 70 79 63 74 09 00 00 |.difflib|.pyct...|
|00002730| 00 5f 5f 63 68 61 69 6e | 5f 62 32 01 00 00 73 2c |.__chain|_b2...s,|
|00002740| 00 00 00 00 0b 09 01 0d | 02 19 01 12 01 11 03 09 |........|........|
|00002750| 01 09 01 06 01 19 01 0c | 01 0d 01 11 03 09 01 0c |........|........|
|00002760| 01 15 01 0e 01 1f 01 12 | 01 0d 01 11 06 0c 01 63 |........|.......c|
|00002770| 05 00 00 00 13 00 00 00 | 10 00 00 00 43 00 00 00 |........|....C...|
|00002780| 73 c0 02 00 00 7c 00 00 | 6a 00 00 7c 00 00 6a 01 |s....|..|j..|..j.|
|00002790| 00 7c 00 00 6a 02 00 7c | 00 00 6a 03 00 66 04 00 |.|..j..||..j..f..|
|000027a0| 5c 04 00 7d 05 00 7d 06 | 00 7d 07 00 7d 08 00 7c |\..}..}.|.}..}..||
|000027b0| 01 00 7c 03 00 64 01 00 | 03 02 7d 09 00 7d 0a 00 |..|..d..|..}..}..|
|000027c0| 7d 0b 00 69 00 00 7d 0c | 00 67 00 00 7d 0d 00 78 |}..i..}.|.g..}..x|
|000027d0| c1 00 74 04 00 7c 01 00 | 7c 02 00 83 02 00 44 5d |..t..|..||.....D]|
|000027e0| b0 00 7d 0e 00 7c 0c 00 | 6a 05 00 7d 0f 00 69 00 |..}..|..|j..}..i.|
|000027f0| 00 7d 10 00 78 92 00 7c | 07 00 6a 05 00 7c 05 00 |.}..x..||..j..|..|
|00002800| 7c 0e 00 19 7c 0d 00 83 | 02 00 44 5d 7a 00 7d 11 ||...|...|..D]z.}.|
|00002810| 00 7c 11 00 7c 03 00 6b | 00 00 72 9e 00 71 86 00 |.|..|..k|..r..q..|
|00002820| 6e 00 00 7c 11 00 7c 04 | 00 6b 05 00 72 ae 00 50 |n..|..|.|.k..r..P|
|00002830| 6e 00 00 7c 0f 00 7c 11 | 00 64 02 00 18 64 01 00 |n..|..|.|.d...d..|
|00002840| 83 02 00 64 02 00 17 04 | 7d 12 00 7c 10 00 7c 11 |...d....|}..|..|.|
|00002850| 00 3c 7c 12 00 7c 0b 00 | 6b 04 00 72 86 00 7c 0e |.<|..|..|k..r..|.|
|00002860| 00 7c 12 00 18 64 02 00 | 17 7c 11 00 7c 12 00 18 |.|...d..|.|..|...|
|00002870| 64 02 00 17 7c 12 00 03 | 02 7d 09 00 7d 0a 00 7d |d...|...|.}..}..}|
|00002880| 0b 00 71 86 00 71 86 00 | 57 7c 10 00 7d 0c 00 71 |..q..q..|W|..}..q|
|00002890| 5a 00 57 78 6d 00 7c 09 | 00 7c 01 00 6b 04 00 72 |Z.Wxm.|.|.|..k..r|
|000028a0| 7d 01 7c 0a 00 7c 03 00 | 6b 04 00 72 7d 01 7c 08 |}.|..|..|k..r}.|.|
|000028b0| 00 7c 06 00 7c 0a 00 64 | 02 00 18 19 83 01 00 0c |.|..|..d|........|
|000028c0| 72 7d 01 7c 05 00 7c 09 | 00 64 02 00 18 19 7c 06 |r}.|..|.|.d....|.|
|000028d0| 00 7c 0a 00 64 02 00 18 | 19 6b 02 00 72 7d 01 7c |.|..d...|.k..r}.||
|000028e0| 09 00 64 02 00 18 7c 0a | 00 64 02 00 18 7c 0b 00 |..d...|.|.d...|..|
|000028f0| 64 02 00 17 03 02 7d 09 | 00 7d 0a 00 7d 0b 00 71 |d.....}.|.}..}..q|
|00002900| 11 01 57 78 5f 00 7c 09 | 00 7c 0b 00 17 7c 02 00 |..Wx_.|.|.|...|..|
|00002910| 6b 00 00 72 df 01 7c 0a | 00 7c 0b 00 17 7c 04 00 |k..r..|.|.|...|..|
|00002920| 6b 00 00 72 df 01 7c 08 | 00 7c 06 00 7c 0a 00 7c |k..r..|.|.|..|..||
|00002930| 0b 00 17 19 83 01 00 0c | 72 df 01 7c 05 00 7c 09 |........|r..|..|.|
|00002940| 00 7c 0b 00 17 19 7c 06 | 00 7c 0a 00 7c 0b 00 17 |.|....|.|.|..|...|
|00002950| 19 6b 02 00 72 df 01 7c | 0b 00 64 02 00 37 7d 0b |.k..r..||..d..7}.|
|00002960| 00 71 81 01 57 78 6c 00 | 7c 09 00 7c 01 00 6b 04 |.q..Wxl.||..|..k.|
|00002970| 00 72 4e 02 7c 0a 00 7c | 03 00 6b 04 00 72 4e 02 |.rN.|..||..k..rN.|
|00002980| 7c 08 00 7c 06 00 7c 0a | 00 64 02 00 18 19 83 01 ||..|..|.|.d......|
|00002990| 00 72 4e 02 7c 05 00 7c | 09 00 64 02 00 18 19 7c |.rN.|..||..d....||
|000029a0| 06 00 7c 0a 00 64 02 00 | 18 19 6b 02 00 72 4e 02 |..|..d..|..k..rN.|
|000029b0| 7c 09 00 64 02 00 18 7c | 0a 00 64 02 00 18 7c 0b ||..d...||..d...|.|
|000029c0| 00 64 02 00 17 03 02 7d | 09 00 7d 0a 00 7d 0b 00 |.d.....}|..}..}..|
|000029d0| 71 e3 01 57 78 5e 00 7c | 09 00 7c 0b 00 17 7c 02 |q..Wx^.||..|...|.|
|000029e0| 00 6b 00 00 72 af 02 7c | 0a 00 7c 0b 00 17 7c 04 |.k..r..||..|...|.|
|000029f0| 00 6b 00 00 72 af 02 7c | 08 00 7c 06 00 7c 0a 00 |.k..r..||..|..|..|
|00002a00| 7c 0b 00 17 19 83 01 00 | 72 af 02 7c 05 00 7c 09 ||.......|r..|..|.|
|00002a10| 00 7c 0b 00 17 19 7c 06 | 00 7c 0a 00 7c 0b 00 17 |.|....|.|.|..|...|
|00002a20| 19 6b 02 00 72 af 02 7c | 0b 00 64 02 00 17 7d 0b |.k..r..||..d...}.|
|00002a30| 00 71 52 02 57 74 06 00 | 7c 09 00 7c 0a 00 7c 0b |.qR.Wt..||..|..|.|
|00002a40| 00 83 03 00 53 28 03 00 | 00 00 73 f2 06 00 00 46 |....S(..|..s....F|
|00002a50| 69 6e 64 20 6c 6f 6e 67 | 65 73 74 20 6d 61 74 63 |ind long|est matc|
|00002a60| 68 69 6e 67 20 62 6c 6f | 63 6b 20 69 6e 20 61 5b |hing blo|ck in a[|
|00002a70| 61 6c 6f 3a 61 68 69 5d | 20 61 6e 64 20 62 5b 62 |alo:ahi]| and b[b|
|00002a80| 6c 6f 3a 62 68 69 5d 2e | 0a 0a 20 20 20 20 20 20 |lo:bhi].|.. |
|00002a90| 20 20 49 66 20 69 73 6a | 75 6e 6b 20 69 73 20 6e | If isj|unk is n|
|00002aa0| 6f 74 20 64 65 66 69 6e | 65 64 3a 0a 0a 20 20 20 |ot defin|ed:.. |
|00002ab0| 20 20 20 20 20 52 65 74 | 75 72 6e 20 28 69 2c 6a | Ret|urn (i,j|
|00002ac0| 2c 6b 29 20 73 75 63 68 | 20 74 68 61 74 20 61 5b |,k) such| that a[|
|00002ad0| 69 3a 69 2b 6b 5d 20 69 | 73 20 65 71 75 61 6c 20 |i:i+k] i|s equal |
|00002ae0| 74 6f 20 62 5b 6a 3a 6a | 2b 6b 5d 2c 20 77 68 65 |to b[j:j|+k], whe|
|00002af0| 72 65 0a 20 20 20 20 20 | 20 20 20 20 20 20 20 61 |re. | a|
|00002b00| 6c 6f 20 3c 3d 20 69 20 | 3c 3d 20 69 2b 6b 20 3c |lo <= i |<= i+k <|
|00002b10| 3d 20 61 68 69 0a 20 20 | 20 20 20 20 20 20 20 20 |= ahi. | |
|00002b20| 20 20 62 6c 6f 20 3c 3d | 20 6a 20 3c 3d 20 6a 2b | blo <=| j <= j+|
|00002b30| 6b 20 3c 3d 20 62 68 69 | 0a 20 20 20 20 20 20 20 |k <= bhi|. |
|00002b40| 20 61 6e 64 20 66 6f 72 | 20 61 6c 6c 20 28 69 27 | and for| all (i'|
|00002b50| 2c 6a 27 2c 6b 27 29 20 | 6d 65 65 74 69 6e 67 20 |,j',k') |meeting |
|00002b60| 74 68 6f 73 65 20 63 6f | 6e 64 69 74 69 6f 6e 73 |those co|nditions|
|00002b70| 2c 0a 20 20 20 20 20 20 | 20 20 20 20 20 20 6b 20 |,. | k |
|00002b80| 3e 3d 20 6b 27 0a 20 20 | 20 20 20 20 20 20 20 20 |>= k'. | |
|00002b90| 20 20 69 20 3c 3d 20 69 | 27 0a 20 20 20 20 20 20 | i <= i|'. |
|00002ba0| 20 20 20 20 20 20 61 6e | 64 20 69 66 20 69 20 3d | an|d if i =|
|00002bb0| 3d 20 69 27 2c 20 6a 20 | 3c 3d 20 6a 27 0a 0a 20 |= i', j |<= j'.. |
|00002bc0| 20 20 20 20 20 20 20 49 | 6e 20 6f 74 68 65 72 20 | I|n other |
|00002bd0| 77 6f 72 64 73 2c 20 6f | 66 20 61 6c 6c 20 6d 61 |words, o|f all ma|
|00002be0| 78 69 6d 61 6c 20 6d 61 | 74 63 68 69 6e 67 20 62 |ximal ma|tching b|
|00002bf0| 6c 6f 63 6b 73 2c 20 72 | 65 74 75 72 6e 20 6f 6e |locks, r|eturn on|
|00002c00| 65 20 74 68 61 74 0a 20 | 20 20 20 20 20 20 20 73 |e that. | s|
|00002c10| 74 61 72 74 73 20 65 61 | 72 6c 69 65 73 74 20 69 |tarts ea|rliest i|
|00002c20| 6e 20 61 2c 20 61 6e 64 | 20 6f 66 20 61 6c 6c 20 |n a, and| of all |
|00002c30| 74 68 6f 73 65 20 6d 61 | 78 69 6d 61 6c 20 6d 61 |those ma|ximal ma|
|00002c40| 74 63 68 69 6e 67 20 62 | 6c 6f 63 6b 73 20 74 68 |tching b|locks th|
|00002c50| 61 74 0a 20 20 20 20 20 | 20 20 20 73 74 61 72 74 |at. | start|
|00002c60| 20 65 61 72 6c 69 65 73 | 74 20 69 6e 20 61 2c 20 | earlies|t in a, |
|00002c70| 72 65 74 75 72 6e 20 74 | 68 65 20 6f 6e 65 20 74 |return t|he one t|
|00002c80| 68 61 74 20 73 74 61 72 | 74 73 20 65 61 72 6c 69 |hat star|ts earli|
|00002c90| 65 73 74 20 69 6e 20 62 | 2e 0a 0a 20 20 20 20 20 |est in b|... |
|00002ca0| 20 20 20 3e 3e 3e 20 73 | 20 3d 20 53 65 71 75 65 | >>> s| = Seque|
|00002cb0| 6e 63 65 4d 61 74 63 68 | 65 72 28 4e 6f 6e 65 2c |nceMatch|er(None,|
|00002cc0| 20 22 20 61 62 63 64 22 | 2c 20 22 61 62 63 64 20 | " abcd"|, "abcd |
|00002cd0| 61 62 63 64 22 29 0a 20 | 20 20 20 20 20 20 20 3e |abcd"). | >|
|00002ce0| 3e 3e 20 73 2e 66 69 6e | 64 5f 6c 6f 6e 67 65 73 |>> s.fin|d_longes|
|00002cf0| 74 5f 6d 61 74 63 68 28 | 30 2c 20 35 2c 20 30 2c |t_match(|0, 5, 0,|
|00002d00| 20 39 29 0a 20 20 20 20 | 20 20 20 20 4d 61 74 63 | 9). | Matc|
|00002d10| 68 28 61 3d 30 2c 20 62 | 3d 34 2c 20 73 69 7a 65 |h(a=0, b|=4, size|
|00002d20| 3d 35 29 0a 0a 20 20 20 | 20 20 20 20 20 49 66 20 |=5).. | If |
|00002d30| 69 73 6a 75 6e 6b 20 69 | 73 20 64 65 66 69 6e 65 |isjunk i|s define|
|00002d40| 64 2c 20 66 69 72 73 74 | 20 74 68 65 20 6c 6f 6e |d, first| the lon|
|00002d50| 67 65 73 74 20 6d 61 74 | 63 68 69 6e 67 20 62 6c |gest mat|ching bl|
|00002d60| 6f 63 6b 20 69 73 0a 20 | 20 20 20 20 20 20 20 64 |ock is. | d|
|00002d70| 65 74 65 72 6d 69 6e 65 | 64 20 61 73 20 61 62 6f |etermine|d as abo|
|00002d80| 76 65 2c 20 62 75 74 20 | 77 69 74 68 20 74 68 65 |ve, but |with the|
|00002d90| 20 61 64 64 69 74 69 6f | 6e 61 6c 20 72 65 73 74 | additio|nal rest|
|00002da0| 72 69 63 74 69 6f 6e 20 | 74 68 61 74 20 6e 6f 0a |riction |that no.|
|00002db0| 20 20 20 20 20 20 20 20 | 6a 75 6e 6b 20 65 6c 65 | |junk ele|
|00002dc0| 6d 65 6e 74 20 61 70 70 | 65 61 72 73 20 69 6e 20 |ment app|ears in |
|00002dd0| 74 68 65 20 62 6c 6f 63 | 6b 2e 20 20 54 68 65 6e |the bloc|k. Then|
|00002de0| 20 74 68 61 74 20 62 6c | 6f 63 6b 20 69 73 20 65 | that bl|ock is e|
|00002df0| 78 74 65 6e 64 65 64 20 | 61 73 0a 20 20 20 20 20 |xtended |as. |
|00002e00| 20 20 20 66 61 72 20 61 | 73 20 70 6f 73 73 69 62 | far a|s possib|
|00002e10| 6c 65 20 62 79 20 6d 61 | 74 63 68 69 6e 67 20 28 |le by ma|tching (|
|00002e20| 6f 6e 6c 79 29 20 6a 75 | 6e 6b 20 65 6c 65 6d 65 |only) ju|nk eleme|
|00002e30| 6e 74 73 20 6f 6e 20 62 | 6f 74 68 20 73 69 64 65 |nts on b|oth side|
|00002e40| 73 2e 20 20 53 6f 0a 20 | 20 20 20 20 20 20 20 74 |s. So. | t|
|00002e50| 68 65 20 72 65 73 75 6c | 74 69 6e 67 20 62 6c 6f |he resul|ting blo|
|00002e60| 63 6b 20 6e 65 76 65 72 | 20 6d 61 74 63 68 65 73 |ck never| matches|
|00002e70| 20 6f 6e 20 6a 75 6e 6b | 20 65 78 63 65 70 74 20 | on junk| except |
|00002e80| 61 73 20 69 64 65 6e 74 | 69 63 61 6c 20 6a 75 6e |as ident|ical jun|
|00002e90| 6b 0a 20 20 20 20 20 20 | 20 20 68 61 70 70 65 6e |k. | happen|
|00002ea0| 73 20 74 6f 20 62 65 20 | 61 64 6a 61 63 65 6e 74 |s to be |adjacent|
|00002eb0| 20 74 6f 20 61 6e 20 22 | 69 6e 74 65 72 65 73 74 | to an "|interest|
|00002ec0| 69 6e 67 22 20 6d 61 74 | 63 68 2e 0a 0a 20 20 20 |ing" mat|ch... |
|00002ed0| 20 20 20 20 20 48 65 72 | 65 27 73 20 74 68 65 20 | Her|e's the |
|00002ee0| 73 61 6d 65 20 65 78 61 | 6d 70 6c 65 20 61 73 20 |same exa|mple as |
|00002ef0| 62 65 66 6f 72 65 2c 20 | 62 75 74 20 63 6f 6e 73 |before, |but cons|
|00002f00| 69 64 65 72 69 6e 67 20 | 62 6c 61 6e 6b 73 20 74 |idering |blanks t|
|00002f10| 6f 20 62 65 0a 20 20 20 | 20 20 20 20 20 6a 75 6e |o be. | jun|
|00002f20| 6b 2e 20 20 54 68 61 74 | 20 70 72 65 76 65 6e 74 |k. That| prevent|
|00002f30| 73 20 22 20 61 62 63 64 | 22 20 66 72 6f 6d 20 6d |s " abcd|" from m|
|00002f40| 61 74 63 68 69 6e 67 20 | 74 68 65 20 22 20 61 62 |atching |the " ab|
|00002f50| 63 64 22 20 61 74 20 74 | 68 65 20 74 61 69 6c 0a |cd" at t|he tail.|
|00002f60| 20 20 20 20 20 20 20 20 | 65 6e 64 20 6f 66 20 74 | |end of t|
|00002f70| 68 65 20 73 65 63 6f 6e | 64 20 73 65 71 75 65 6e |he secon|d sequen|
|00002f80| 63 65 20 64 69 72 65 63 | 74 6c 79 2e 20 20 49 6e |ce direc|tly. In|
|00002f90| 73 74 65 61 64 20 6f 6e | 6c 79 20 74 68 65 20 22 |stead on|ly the "|
|00002fa0| 61 62 63 64 22 20 63 61 | 6e 0a 20 20 20 20 20 20 |abcd" ca|n. |
|00002fb0| 20 20 6d 61 74 63 68 2c | 20 61 6e 64 20 6d 61 74 | match,| and mat|
|00002fc0| 63 68 65 73 20 74 68 65 | 20 6c 65 66 74 6d 6f 73 |ches the| leftmos|
|00002fd0| 74 20 22 61 62 63 64 22 | 20 69 6e 20 74 68 65 20 |t "abcd"| in the |
|00002fe0| 73 65 63 6f 6e 64 20 73 | 65 71 75 65 6e 63 65 3a |second s|equence:|
|00002ff0| 0a 0a 20 20 20 20 20 20 | 20 20 3e 3e 3e 20 73 20 |.. | >>> s |
|00003000| 3d 20 53 65 71 75 65 6e | 63 65 4d 61 74 63 68 65 |= Sequen|ceMatche|
|00003010| 72 28 6c 61 6d 62 64 61 | 20 78 3a 20 78 3d 3d 22 |r(lambda| x: x=="|
|00003020| 20 22 2c 20 22 20 61 62 | 63 64 22 2c 20 22 61 62 | ", " ab|cd", "ab|
|00003030| 63 64 20 61 62 63 64 22 | 29 0a 20 20 20 20 20 20 |cd abcd"|). |
|00003040| 20 20 3e 3e 3e 20 73 2e | 66 69 6e 64 5f 6c 6f 6e | >>> s.|find_lon|
|00003050| 67 65 73 74 5f 6d 61 74 | 63 68 28 30 2c 20 35 2c |gest_mat|ch(0, 5,|
|00003060| 20 30 2c 20 39 29 0a 20 | 20 20 20 20 20 20 20 4d | 0, 9). | M|
|00003070| 61 74 63 68 28 61 3d 31 | 2c 20 62 3d 30 2c 20 73 |atch(a=1|, b=0, s|
|00003080| 69 7a 65 3d 34 29 0a 0a | 20 20 20 20 20 20 20 20 |ize=4)..| |
|00003090| 49 66 20 6e 6f 20 62 6c | 6f 63 6b 73 20 6d 61 74 |If no bl|ocks mat|
|000030a0| 63 68 2c 20 72 65 74 75 | 72 6e 20 28 61 6c 6f 2c |ch, retu|rn (alo,|
|000030b0| 20 62 6c 6f 2c 20 30 29 | 2e 0a 0a 20 20 20 20 20 | blo, 0)|... |
|000030c0| 20 20 20 3e 3e 3e 20 73 | 20 3d 20 53 65 71 75 65 | >>> s| = Seque|
|000030d0| 6e 63 65 4d 61 74 63 68 | 65 72 28 4e 6f 6e 65 2c |nceMatch|er(None,|
|000030e0| 20 22 61 62 22 2c 20 22 | 63 22 29 0a 20 20 20 20 | "ab", "|c"). |
|000030f0| 20 20 20 20 3e 3e 3e 20 | 73 2e 66 69 6e 64 5f 6c | >>> |s.find_l|
|00003100| 6f 6e 67 65 73 74 5f 6d | 61 74 63 68 28 30 2c 20 |ongest_m|atch(0, |
|00003110| 32 2c 20 30 2c 20 31 29 | 0a 20 20 20 20 20 20 20 |2, 0, 1)|. |
|00003120| 20 4d 61 74 63 68 28 61 | 3d 30 2c 20 62 3d 30 2c | Match(a|=0, b=0,|
|00003130| 20 73 69 7a 65 3d 30 29 | 0a 20 20 20 20 20 20 20 | size=0)|. |
|00003140| 20 69 00 00 00 00 69 01 | 00 00 00 28 07 00 00 00 | i....i.|...(....|
|00003150| 52 13 00 00 00 52 14 00 | 00 00 52 1f 00 00 00 52 |R....R..|..R....R|
|00003160| 2a 00 00 00 74 06 00 00 | 00 78 72 61 6e 67 65 74 |*...t...|.xranget|
|00003170| 03 00 00 00 67 65 74 52 | 0a 00 00 00 28 13 00 00 |....getR|....(...|
|00003180| 00 52 17 00 00 00 74 03 | 00 00 00 61 6c 6f 74 03 |.R....t.|...alot.|
|00003190| 00 00 00 61 68 69 74 03 | 00 00 00 62 6c 6f 74 03 |...ahit.|...blot.|
|000031a0| 00 00 00 62 68 69 52 13 | 00 00 00 52 14 00 00 00 |...bhiR.|...R....|
|000031b0| 52 1f 00 00 00 52 2a 00 | 00 00 74 05 00 00 00 62 |R....R*.|..t....b|
|000031c0| 65 73 74 69 74 05 00 00 | 00 62 65 73 74 6a 74 08 |estit...|.bestjt.|
|000031d0| 00 00 00 62 65 73 74 73 | 69 7a 65 74 05 00 00 00 |...bests|izet....|
|000031e0| 6a 32 6c 65 6e 74 07 00 | 00 00 6e 6f 74 68 69 6e |j2lent..|..nothin|
|000031f0| 67 52 2c 00 00 00 74 08 | 00 00 00 6a 32 6c 65 6e |gR,...t.|...j2len|
|00003200| 67 65 74 74 08 00 00 00 | 6e 65 77 6a 32 6c 65 6e |gett....|newj2len|
|00003210| 74 01 00 00 00 6a 74 01 | 00 00 00 6b 28 00 00 00 |t....jt.|...k(...|
|00003220| 00 28 00 00 00 00 73 0b | 00 00 00 64 69 66 66 6c |.(....s.|...diffl|
|00003230| 69 62 2e 70 79 63 74 12 | 00 00 00 66 69 6e 64 5f |ib.pyct.|...find_|
|00003240| 6c 6f 6e 67 65 73 74 5f | 6d 61 74 63 68 5e 01 00 |longest_|match^..|
|00003250| 00 73 42 00 00 00 00 38 | 2a 01 14 04 06 01 06 01 |.sB....8|*.......|
|00003260| 16 03 09 01 06 01 1d 02 | 0c 01 06 01 0c 01 04 01 |........|........|
|00003270| 1f 01 0c 01 2b 01 0a 06 | 1b 01 15 01 1c 01 24 01 |....+...|......$.|
|00003280| 23 01 15 01 1c 01 0e 09 | 1b 01 14 01 1c 01 24 01 |#.......|......$.|
|00003290| 23 01 14 01 1c 01 0e 02 | 63 01 00 00 00 14 00 00 |#.......|c.......|
|000032a0| 00 07 00 00 00 43 00 00 | 00 73 11 02 00 00 7c 00 |.....C..|.s....|.|
|000032b0| 00 6a 00 00 64 02 00 6b | 09 00 72 16 00 7c 00 00 |.j..d..k|..r..|..|
|000032c0| 6a 00 00 53 74 02 00 7c | 00 00 6a 03 00 83 01 00 |j..St..||..j.....|
|000032d0| 74 02 00 7c 00 00 6a 04 | 00 83 01 00 02 7d 01 00 |t..|..j.|.....}..|
|000032e0| 7d 02 00 64 01 00 7c 01 | 00 64 01 00 7c 02 00 66 |}..d..|.|.d..|..f|
|000032f0| 04 00 67 01 00 7d 03 00 | 67 00 00 7d 04 00 78 d5 |..g..}..|g..}..x.|
|00003300| 00 7c 03 00 72 27 01 7c | 03 00 6a 05 00 83 00 00 |.|..r'.||..j.....|
|00003310| 5c 04 00 7d 05 00 7d 06 | 00 7d 07 00 7d 08 00 7c |\..}..}.|.}..}..||
|00003320| 00 00 6a 06 00 7c 05 00 | 7c 06 00 7c 07 00 7c 08 |..j..|..||..|..|.|
|00003330| 00 83 04 00 04 5c 03 00 | 7d 09 00 7d 0a 00 7d 0b |.....\..|}..}..}.|
|00003340| 00 7d 0c 00 7c 0b 00 72 | 53 00 7c 04 00 6a 07 00 |.}..|..r|S.|..j..|
|00003350| 7c 0c 00 83 01 00 01 7c | 05 00 7c 09 00 6b 00 00 ||......||..|..k..|
|00003360| 72 dd 00 7c 07 00 7c 0a | 00 6b 00 00 72 dd 00 7c |r..|..|.|.k..r..||
|00003370| 03 00 6a 07 00 7c 05 00 | 7c 09 00 7c 07 00 7c 0a |..j..|..||..|..|.|
|00003380| 00 66 04 00 83 01 00 01 | 6e 00 00 7c 09 00 7c 0b |.f......|n..|..|.|
|00003390| 00 17 7c 06 00 6b 00 00 | 72 24 01 7c 0a 00 7c 0b |..|..k..|r$.|..|.|
|000033a0| 00 17 7c 08 00 6b 00 00 | 72 24 01 7c 03 00 6a 07 |..|..k..|r$.|..j.|
|000033b0| 00 7c 09 00 7c 0b 00 17 | 7c 06 00 7c 0a 00 7c 0b |.|..|...||..|..|.|
|000033c0| 00 17 7c 08 00 66 04 00 | 83 01 00 01 71 24 01 71 |..|..f..|....q$.q|
|000033d0| 53 00 71 53 00 57 7c 04 | 00 6a 08 00 83 00 00 01 |S.qS.W|.|.j......|
|000033e0| 64 01 00 04 7d 0d 00 04 | 7d 0e 00 7d 0f 00 67 00 |d...}...|}..}..g.|
|000033f0| 00 7d 10 00 78 77 00 7c | 04 00 44 5d 6f 00 5c 03 |.}..xw.||..D]o.\.|
|00003400| 00 7d 11 00 7d 12 00 7d | 13 00 7c 0d 00 7c 0f 00 |.}..}..}|..|..|..|
|00003410| 17 7c 11 00 6b 02 00 72 | 89 01 7c 0e 00 7c 0f 00 |.|..k..r|..|..|..|
|00003420| 17 7c 12 00 6b 02 00 72 | 89 01 7c 0f 00 7c 13 00 |.|..k..r|..|..|..|
|00003430| 37 7d 0f 00 71 4d 01 7c | 0f 00 72 a8 01 7c 10 00 |7}..qM.||..r..|..|
|00003440| 6a 07 00 7c 0d 00 7c 0e | 00 7c 0f 00 66 03 00 83 |j..|..|.|.|..f...|
|00003450| 01 00 01 6e 00 00 7c 11 | 00 7c 12 00 7c 13 00 03 |...n..|.|.|..|...|
|00003460| 02 7d 0d 00 7d 0e 00 7d | 0f 00 71 4d 01 57 7c 0f |.}..}..}|..qM.W|.|
|00003470| 00 72 df 01 7c 10 00 6a | 07 00 7c 0d 00 7c 0e 00 |.r..|..j|..|..|..|
|00003480| 7c 0f 00 66 03 00 83 01 | 00 01 6e 00 00 7c 10 00 ||..f....|..n..|..|
|00003490| 6a 07 00 7c 01 00 7c 02 | 00 64 01 00 66 03 00 83 |j..|..|.|.d..f...|
|000034a0| 01 00 01 7c 10 00 7c 00 | 00 5f 00 00 74 09 00 74 |...|..|.|._..t..t|
|000034b0| 0a 00 6a 0b 00 7c 00 00 | 6a 00 00 83 02 00 53 28 |..j..|..|j.....S(|
|000034c0| 03 00 00 00 73 0d 03 00 | 00 52 65 74 75 72 6e 20 |....s...|.Return |
|000034d0| 6c 69 73 74 20 6f 66 20 | 74 72 69 70 6c 65 73 20 |list of |triples |
|000034e0| 64 65 73 63 72 69 62 69 | 6e 67 20 6d 61 74 63 68 |describi|ng match|
|000034f0| 69 6e 67 20 73 75 62 73 | 65 71 75 65 6e 63 65 73 |ing subs|equences|
|00003500| 2e 0a 0a 20 20 20 20 20 | 20 20 20 45 61 63 68 20 |... | Each |
|00003510| 74 72 69 70 6c 65 20 69 | 73 20 6f 66 20 74 68 65 |triple i|s of the|
|00003520| 20 66 6f 72 6d 20 28 69 | 2c 20 6a 2c 20 6e 29 2c | form (i|, j, n),|
|00003530| 20 61 6e 64 20 6d 65 61 | 6e 73 20 74 68 61 74 0a | and mea|ns that.|
|00003540| 20 20 20 20 20 20 20 20 | 61 5b 69 3a 69 2b 6e 5d | |a[i:i+n]|
|00003550| 20 3d 3d 20 62 5b 6a 3a | 6a 2b 6e 5d 2e 20 20 54 | == b[j:|j+n]. T|
|00003560| 68 65 20 74 72 69 70 6c | 65 73 20 61 72 65 20 6d |he tripl|es are m|
|00003570| 6f 6e 6f 74 6f 6e 69 63 | 61 6c 6c 79 20 69 6e 63 |onotonic|ally inc|
|00003580| 72 65 61 73 69 6e 67 20 | 69 6e 0a 20 20 20 20 20 |reasing |in. |
|00003590| 20 20 20 69 20 61 6e 64 | 20 69 6e 20 6a 2e 20 20 | i and| in j. |
|000035a0| 4e 65 77 20 69 6e 20 50 | 79 74 68 6f 6e 20 32 2e |New in P|ython 2.|
|000035b0| 35 2c 20 69 74 27 73 20 | 61 6c 73 6f 20 67 75 61 |5, it's |also gua|
|000035c0| 72 61 6e 74 65 65 64 20 | 74 68 61 74 20 69 66 0a |ranteed |that if.|
|000035d0| 20 20 20 20 20 20 20 20 | 28 69 2c 20 6a 2c 20 6e | |(i, j, n|
|000035e0| 29 20 61 6e 64 20 28 69 | 27 2c 20 6a 27 2c 20 6e |) and (i|', j', n|
|000035f0| 27 29 20 61 72 65 20 61 | 64 6a 61 63 65 6e 74 20 |') are a|djacent |
|00003600| 74 72 69 70 6c 65 73 20 | 69 6e 20 74 68 65 20 6c |triples |in the l|
|00003610| 69 73 74 2c 20 61 6e 64 | 0a 20 20 20 20 20 20 20 |ist, and|. |
|00003620| 20 74 68 65 20 73 65 63 | 6f 6e 64 20 69 73 20 6e | the sec|ond is n|
|00003630| 6f 74 20 74 68 65 20 6c | 61 73 74 20 74 72 69 70 |ot the l|ast trip|
|00003640| 6c 65 20 69 6e 20 74 68 | 65 20 6c 69 73 74 2c 20 |le in th|e list, |
|00003650| 74 68 65 6e 20 69 2b 6e | 20 21 3d 20 69 27 20 6f |then i+n| != i' o|
|00003660| 72 0a 20 20 20 20 20 20 | 20 20 6a 2b 6e 20 21 3d |r. | j+n !=|
|00003670| 20 6a 27 2e 20 20 49 4f | 57 2c 20 61 64 6a 61 63 | j'. IO|W, adjac|
|00003680| 65 6e 74 20 74 72 69 70 | 6c 65 73 20 6e 65 76 65 |ent trip|les neve|
|00003690| 72 20 64 65 73 63 72 69 | 62 65 20 61 64 6a 61 63 |r descri|be adjac|
|000036a0| 65 6e 74 20 65 71 75 61 | 6c 0a 20 20 20 20 20 20 |ent equa|l. |
|000036b0| 20 20 62 6c 6f 63 6b 73 | 2e 0a 0a 20 20 20 20 20 | blocks|... |
|000036c0| 20 20 20 54 68 65 20 6c | 61 73 74 20 74 72 69 70 | The l|ast trip|
|000036d0| 6c 65 20 69 73 20 61 20 | 64 75 6d 6d 79 2c 20 28 |le is a |dummy, (|
|000036e0| 6c 65 6e 28 61 29 2c 20 | 6c 65 6e 28 62 29 2c 20 |len(a), |len(b), |
|000036f0| 30 29 2c 20 61 6e 64 20 | 69 73 20 74 68 65 20 6f |0), and |is the o|
|00003700| 6e 6c 79 0a 20 20 20 20 | 20 20 20 20 74 72 69 70 |nly. | trip|
|00003710| 6c 65 20 77 69 74 68 20 | 6e 3d 3d 30 2e 0a 0a 20 |le with |n==0... |
|00003720| 20 20 20 20 20 20 20 3e | 3e 3e 20 73 20 3d 20 53 | >|>> s = S|
|00003730| 65 71 75 65 6e 63 65 4d | 61 74 63 68 65 72 28 4e |equenceM|atcher(N|
|00003740| 6f 6e 65 2c 20 22 61 62 | 78 63 64 22 2c 20 22 61 |one, "ab|xcd", "a|
|00003750| 62 63 64 22 29 0a 20 20 | 20 20 20 20 20 20 3e 3e |bcd"). | >>|
|00003760| 3e 20 73 2e 67 65 74 5f | 6d 61 74 63 68 69 6e 67 |> s.get_|matching|
|00003770| 5f 62 6c 6f 63 6b 73 28 | 29 0a 20 20 20 20 20 20 |_blocks(|). |
|00003780| 20 20 5b 4d 61 74 63 68 | 28 61 3d 30 2c 20 62 3d | [Match|(a=0, b=|
|00003790| 30 2c 20 73 69 7a 65 3d | 32 29 2c 20 4d 61 74 63 |0, size=|2), Matc|
|000037a0| 68 28 61 3d 33 2c 20 62 | 3d 32 2c 20 73 69 7a 65 |h(a=3, b|=2, size|
|000037b0| 3d 32 29 2c 20 4d 61 74 | 63 68 28 61 3d 35 2c 20 |=2), Mat|ch(a=5, |
|000037c0| 62 3d 34 2c 20 73 69 7a | 65 3d 30 29 5d 0a 20 20 |b=4, siz|e=0)]. |
|000037d0| 20 20 20 20 20 20 69 00 | 00 00 00 4e 28 0c 00 00 | i.|...N(...|
|000037e0| 00 52 1b 00 00 00 52 12 | 00 00 00 52 27 00 00 00 |.R....R.|...R'...|
|000037f0| 52 13 00 00 00 52 14 00 | 00 00 74 03 00 00 00 70 |R....R..|..t....p|
|00003800| 6f 70 52 44 00 00 00 52 | 22 00 00 00 74 04 00 00 |opRD...R|"...t...|
|00003810| 00 73 6f 72 74 74 03 00 | 00 00 6d 61 70 52 0a 00 |.sortt..|..mapR..|
|00003820| 00 00 74 05 00 00 00 5f | 6d 61 6b 65 28 14 00 00 |..t...._|make(...|
|00003830| 00 52 17 00 00 00 74 02 | 00 00 00 6c 61 74 02 00 |.R....t.|...lat..|
|00003840| 00 00 6c 62 74 05 00 00 | 00 71 75 65 75 65 52 1b |..lbt...|.queueR.|
|00003850| 00 00 00 52 37 00 00 00 | 52 38 00 00 00 52 39 00 |...R7...|R8...R9.|
|00003860| 00 00 52 3a 00 00 00 52 | 2c 00 00 00 52 42 00 00 |..R:...R|,...RB..|
|00003870| 00 52 43 00 00 00 74 01 | 00 00 00 78 74 02 00 00 |.RC...t.|...xt...|
|00003880| 00 69 31 74 02 00 00 00 | 6a 31 74 02 00 00 00 6b |.i1t....|j1t....k|
|00003890| 31 74 0c 00 00 00 6e 6f | 6e 5f 61 64 6a 61 63 65 |1t....no|n_adjace|
|000038a0| 6e 74 74 02 00 00 00 69 | 32 74 02 00 00 00 6a 32 |ntt....i|2t....j2|
|000038b0| 74 02 00 00 00 6b 32 28 | 00 00 00 00 28 00 00 00 |t....k2(|....(...|
|000038c0| 00 73 0b 00 00 00 64 69 | 66 66 6c 69 62 2e 70 79 |.s....di|fflib.py|
|000038d0| 63 74 13 00 00 00 67 65 | 74 5f 6d 61 74 63 68 69 |ct....ge|t_matchi|
|000038e0| 6e 67 5f 62 6c 6f 63 6b | 73 cc 01 00 00 73 38 00 |ng_block|s....s8.|
|000038f0| 00 00 00 13 0f 01 07 01 | 1f 08 15 01 06 01 09 01 |........|........|
|00003900| 18 01 25 04 06 01 0d 01 | 18 01 1c 01 20 01 2b 01 |..%.....|.... .+.|
|00003910| 0a 05 0e 01 06 01 16 02 | 20 04 0d 05 06 01 19 01 |........| .......|
|00003920| 18 01 06 01 19 02 16 01 | 09 01 63 01 00 00 00 08 |........|..c.....|
|00003930| 00 00 00 08 00 00 00 43 | 00 00 00 73 01 01 00 00 |.......C|...s....|
|00003940| 7c 00 00 6a 00 00 64 07 | 00 6b 09 00 72 16 00 7c ||..j..d.|.k..r..||
|00003950| 00 00 6a 00 00 53 64 01 | 00 04 7d 01 00 7d 02 00 |..j..Sd.|..}..}..|
|00003960| 67 00 00 04 7c 00 00 5f | 00 00 7d 03 00 78 cd 00 |g...|.._|..}..x..|
|00003970| 7c 00 00 6a 02 00 83 00 | 00 44 5d bf 00 5c 03 00 ||..j....|.D]..\..|
|00003980| 7d 04 00 7d 05 00 7d 06 | 00 64 02 00 7d 07 00 7c |}..}..}.|.d..}..||
|00003990| 01 00 7c 04 00 6b 00 00 | 72 70 00 7c 02 00 7c 05 |..|..k..|rp.|..|.|
|000039a0| 00 6b 00 00 72 70 00 64 | 03 00 7d 07 00 6e 2a 00 |.k..rp.d|..}..n*.|
|000039b0| 7c 01 00 7c 04 00 6b 00 | 00 72 85 00 64 04 00 7d ||..|..k.|.r..d..}|
|000039c0| 07 00 6e 15 00 7c 02 00 | 7c 05 00 6b 00 00 72 9a |..n..|..||..k..r.|
|000039d0| 00 64 05 00 7d 07 00 6e | 00 00 7c 07 00 72 bf 00 |.d..}..n|..|..r..|
|000039e0| 7c 03 00 6a 03 00 7c 07 | 00 7c 01 00 7c 04 00 7c ||..j..|.|.|..|..||
|000039f0| 02 00 7c 05 00 66 05 00 | 83 01 00 01 6e 00 00 7c |..|..f..|....n..||
|00003a00| 04 00 7c 06 00 17 7c 05 | 00 7c 06 00 17 02 7d 01 |..|...|.|.|....}.|
|00003a10| 00 7d 02 00 7c 06 00 72 | 3a 00 7c 03 00 6a 03 00 |.}..|..r|:.|..j..|
|00003a20| 64 06 00 7c 04 00 7c 01 | 00 7c 05 00 7c 02 00 66 |d..|..|.|.|..|..f|
|00003a30| 05 00 83 01 00 01 71 3a | 00 71 3a 00 57 7c 03 00 |......q:|.q:.W|..|
|00003a40| 53 28 08 00 00 00 73 5a | 04 00 00 52 65 74 75 72 |S(....sZ|...Retur|
|00003a50| 6e 20 6c 69 73 74 20 6f | 66 20 35 2d 74 75 70 6c |n list o|f 5-tupl|
|00003a60| 65 73 20 64 65 73 63 72 | 69 62 69 6e 67 20 68 6f |es descr|ibing ho|
|00003a70| 77 20 74 6f 20 74 75 72 | 6e 20 61 20 69 6e 74 6f |w to tur|n a into|
|00003a80| 20 62 2e 0a 0a 20 20 20 | 20 20 20 20 20 45 61 63 | b... | Eac|
|00003a90| 68 20 74 75 70 6c 65 20 | 69 73 20 6f 66 20 74 68 |h tuple |is of th|
|00003aa0| 65 20 66 6f 72 6d 20 28 | 74 61 67 2c 20 69 31 2c |e form (|tag, i1,|
|00003ab0| 20 69 32 2c 20 6a 31 2c | 20 6a 32 29 2e 20 20 54 | i2, j1,| j2). T|
|00003ac0| 68 65 20 66 69 72 73 74 | 20 74 75 70 6c 65 0a 20 |he first| tuple. |
|00003ad0| 20 20 20 20 20 20 20 68 | 61 73 20 69 31 20 3d 3d | h|as i1 ==|
|00003ae0| 20 6a 31 20 3d 3d 20 30 | 2c 20 61 6e 64 20 72 65 | j1 == 0|, and re|
|00003af0| 6d 61 69 6e 69 6e 67 20 | 74 75 70 6c 65 73 20 68 |maining |tuples h|
|00003b00| 61 76 65 20 69 31 20 3d | 3d 20 74 68 65 20 69 32 |ave i1 =|= the i2|
|00003b10| 20 66 72 6f 6d 20 74 68 | 65 0a 20 20 20 20 20 20 | from th|e. |
|00003b20| 20 20 74 75 70 6c 65 20 | 70 72 65 63 65 64 69 6e | tuple |precedin|
|00003b30| 67 20 69 74 2c 20 61 6e | 64 20 6c 69 6b 65 77 69 |g it, an|d likewi|
|00003b40| 73 65 20 66 6f 72 20 6a | 31 20 3d 3d 20 74 68 65 |se for j|1 == the|
|00003b50| 20 70 72 65 76 69 6f 75 | 73 20 6a 32 2e 0a 0a 20 | previou|s j2... |
|00003b60| 20 20 20 20 20 20 20 54 | 68 65 20 74 61 67 73 20 | T|he tags |
|00003b70| 61 72 65 20 73 74 72 69 | 6e 67 73 2c 20 77 69 74 |are stri|ngs, wit|
|00003b80| 68 20 74 68 65 73 65 20 | 6d 65 61 6e 69 6e 67 73 |h these |meanings|
|00003b90| 3a 0a 0a 20 20 20 20 20 | 20 20 20 27 72 65 70 6c |:.. | 'repl|
|00003ba0| 61 63 65 27 3a 20 20 61 | 5b 69 31 3a 69 32 5d 20 |ace': a|[i1:i2] |
|00003bb0| 73 68 6f 75 6c 64 20 62 | 65 20 72 65 70 6c 61 63 |should b|e replac|
|00003bc0| 65 64 20 62 79 20 62 5b | 6a 31 3a 6a 32 5d 0a 20 |ed by b[|j1:j2]. |
|00003bd0| 20 20 20 20 20 20 20 27 | 64 65 6c 65 74 65 27 3a | '|delete':|
|00003be0| 20 20 20 61 5b 69 31 3a | 69 32 5d 20 73 68 6f 75 | a[i1:|i2] shou|
|00003bf0| 6c 64 20 62 65 20 64 65 | 6c 65 74 65 64 2e 0a 20 |ld be de|leted.. |
|00003c00| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00003c10| 20 20 20 4e 6f 74 65 20 | 74 68 61 74 20 6a 31 3d | Note |that j1=|
|00003c20| 3d 6a 32 20 69 6e 20 74 | 68 69 73 20 63 61 73 65 |=j2 in t|his case|
|00003c30| 2e 0a 20 20 20 20 20 20 | 20 20 27 69 6e 73 65 72 |.. | 'inser|
|00003c40| 74 27 3a 20 20 20 62 5b | 6a 31 3a 6a 32 5d 20 73 |t': b[|j1:j2] s|
|00003c50| 68 6f 75 6c 64 20 62 65 | 20 69 6e 73 65 72 74 65 |hould be| inserte|
|00003c60| 64 20 61 74 20 61 5b 69 | 31 3a 69 31 5d 2e 0a 20 |d at a[i|1:i1].. |
|00003c70| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00003c80| 20 20 20 4e 6f 74 65 20 | 74 68 61 74 20 69 31 3d | Note |that i1=|
|00003c90| 3d 69 32 20 69 6e 20 74 | 68 69 73 20 63 61 73 65 |=i2 in t|his case|
|00003ca0| 2e 0a 20 20 20 20 20 20 | 20 20 27 65 71 75 61 6c |.. | 'equal|
|00003cb0| 27 3a 20 20 20 20 61 5b | 69 31 3a 69 32 5d 20 3d |': a[|i1:i2] =|
|00003cc0| 3d 20 62 5b 6a 31 3a 6a | 32 5d 0a 0a 20 20 20 20 |= b[j1:j|2].. |
|00003cd0| 20 20 20 20 3e 3e 3e 20 | 61 20 3d 20 22 71 61 62 | >>> |a = "qab|
|00003ce0| 78 63 64 22 0a 20 20 20 | 20 20 20 20 20 3e 3e 3e |xcd". | >>>|
|00003cf0| 20 62 20 3d 20 22 61 62 | 79 63 64 66 22 0a 20 20 | b = "ab|ycdf". |
|00003d00| 20 20 20 20 20 20 3e 3e | 3e 20 73 20 3d 20 53 65 | >>|> s = Se|
|00003d10| 71 75 65 6e 63 65 4d 61 | 74 63 68 65 72 28 4e 6f |quenceMa|tcher(No|
|00003d20| 6e 65 2c 20 61 2c 20 62 | 29 0a 20 20 20 20 20 20 |ne, a, b|). |
|00003d30| 20 20 3e 3e 3e 20 66 6f | 72 20 74 61 67 2c 20 69 | >>> fo|r tag, i|
|00003d40| 31 2c 20 69 32 2c 20 6a | 31 2c 20 6a 32 20 69 6e |1, i2, j|1, j2 in|
|00003d50| 20 73 2e 67 65 74 5f 6f | 70 63 6f 64 65 73 28 29 | s.get_o|pcodes()|
|00003d60| 3a 0a 20 20 20 20 20 20 | 20 20 2e 2e 2e 20 20 20 |:. | ... |
|00003d70| 20 70 72 69 6e 74 20 28 | 22 25 37 73 20 61 5b 25 | print (|"%7s a[%|
|00003d80| 64 3a 25 64 5d 20 28 25 | 73 29 20 62 5b 25 64 3a |d:%d] (%|s) b[%d:|
|00003d90| 25 64 5d 20 28 25 73 29 | 22 20 25 0a 20 20 20 20 |%d] (%s)|" %. |
|00003da0| 20 20 20 20 2e 2e 2e 20 | 20 20 20 20 20 20 20 20 | ... | |
|00003db0| 20 20 28 74 61 67 2c 20 | 69 31 2c 20 69 32 2c 20 | (tag, |i1, i2, |
|00003dc0| 61 5b 69 31 3a 69 32 5d | 2c 20 6a 31 2c 20 6a 32 |a[i1:i2]|, j1, j2|
|00003dd0| 2c 20 62 5b 6a 31 3a 6a | 32 5d 29 29 0a 20 20 20 |, b[j1:j|2])). |
|00003de0| 20 20 20 20 20 20 64 65 | 6c 65 74 65 20 61 5b 30 | de|lete a[0|
|00003df0| 3a 31 5d 20 28 71 29 20 | 62 5b 30 3a 30 5d 20 28 |:1] (q) |b[0:0] (|
|00003e00| 29 0a 20 20 20 20 20 20 | 20 20 20 20 65 71 75 61 |). | equa|
|00003e10| 6c 20 61 5b 31 3a 33 5d | 20 28 61 62 29 20 62 5b |l a[1:3]| (ab) b[|
|00003e20| 30 3a 32 5d 20 28 61 62 | 29 0a 20 20 20 20 20 20 |0:2] (ab|). |
|00003e30| 20 20 72 65 70 6c 61 63 | 65 20 61 5b 33 3a 34 5d | replac|e a[3:4]|
|00003e40| 20 28 78 29 20 62 5b 32 | 3a 33 5d 20 28 79 29 0a | (x) b[2|:3] (y).|
|00003e50| 20 20 20 20 20 20 20 20 | 20 20 65 71 75 61 6c 20 | | equal |
|00003e60| 61 5b 34 3a 36 5d 20 28 | 63 64 29 20 62 5b 33 3a |a[4:6] (|cd) b[3:|
|00003e70| 35 5d 20 28 63 64 29 0a | 20 20 20 20 20 20 20 20 |5] (cd).| |
|00003e80| 20 69 6e 73 65 72 74 20 | 61 5b 36 3a 36 5d 20 28 | insert |a[6:6] (|
|00003e90| 29 20 62 5b 35 3a 36 5d | 20 28 66 29 0a 20 20 20 |) b[5:6]| (f). |
|00003ea0| 20 20 20 20 20 69 00 00 | 00 00 52 10 00 00 00 74 | i..|..R....t|
|00003eb0| 07 00 00 00 72 65 70 6c | 61 63 65 74 06 00 00 00 |....repl|acet....|
|00003ec0| 64 65 6c 65 74 65 74 06 | 00 00 00 69 6e 73 65 72 |deletet.|...inser|
|00003ed0| 74 74 05 00 00 00 65 71 | 75 61 6c 4e 28 04 00 00 |tt....eq|ualN(...|
|00003ee0| 00 52 1c 00 00 00 52 12 | 00 00 00 52 54 00 00 00 |.R....R.|...RT...|
|00003ef0| 52 22 00 00 00 28 08 00 | 00 00 52 17 00 00 00 52 |R"...(..|..R....R|
|00003f00| 2c 00 00 00 52 42 00 00 | 00 74 06 00 00 00 61 6e |,...RB..|.t....an|
|00003f10| 73 77 65 72 74 02 00 00 | 00 61 69 74 02 00 00 00 |swert...|.ait....|
|00003f20| 62 6a 74 04 00 00 00 73 | 69 7a 65 74 03 00 00 00 |bjt....s|izet....|
|00003f30| 74 61 67 28 00 00 00 00 | 28 00 00 00 00 73 0b 00 |tag(....|(....s..|
|00003f40| 00 00 64 69 66 66 6c 69 | 62 2e 70 79 63 74 0b 00 |..diffli|b.pyct..|
|00003f50| 00 00 67 65 74 5f 6f 70 | 63 6f 64 65 73 13 02 00 |..get_op|codes...|
|00003f60| 00 73 24 00 00 00 00 1d | 0f 01 07 01 0a 01 0d 01 |.s$.....|........|
|00003f70| 1c 06 06 01 18 01 09 01 | 0c 01 09 01 0c 01 09 01 |........|........|
|00003f80| 06 01 1f 01 15 03 06 01 | 23 01 69 03 00 00 00 63 |........|#.i....c|
|00003f90| 02 00 00 00 0a 00 00 00 | 0b 00 00 00 63 00 00 00 |........|....c...|
|00003fa0| 73 f0 01 00 00 7c 00 00 | 6a 00 00 83 00 00 7d 02 |s....|..|j.....}.|
|00003fb0| 00 7c 02 00 73 1e 00 64 | 06 00 67 01 00 7d 02 00 |.|..s..d|..g..}..|
|00003fc0| 6e 00 00 7c 02 00 64 02 | 00 19 64 02 00 19 64 01 |n..|..d.|..d...d.|
|00003fd0| 00 6b 02 00 72 81 00 7c | 02 00 64 02 00 19 5c 05 |.k..r..||..d...\.|
|00003fe0| 00 7d 03 00 7d 04 00 7d | 05 00 7d 06 00 7d 07 00 |.}..}..}|..}..}..|
|00003ff0| 7c 03 00 74 01 00 7c 04 | 00 7c 05 00 7c 01 00 18 ||..t..|.|.|..|...|
|00004000| 83 02 00 7c 05 00 74 01 | 00 7c 06 00 7c 07 00 7c |...|..t.|.|..|..||
|00004010| 01 00 18 83 02 00 7c 07 | 00 66 05 00 7c 02 00 64 |......|.|.f..|..d|
|00004020| 02 00 3c 6e 00 00 7c 02 | 00 64 04 00 19 64 02 00 |..<n..|.|.d...d..|
|00004030| 19 64 01 00 6b 02 00 72 | e4 00 7c 02 00 64 04 00 |.d..k..r|..|..d..|
|00004040| 19 5c 05 00 7d 03 00 7d | 04 00 7d 05 00 7d 06 00 |.\..}..}|..}..}..|
|00004050| 7d 07 00 7c 03 00 7c 04 | 00 74 02 00 7c 05 00 7c |}..|..|.|.t..|..||
|00004060| 04 00 7c 01 00 17 83 02 | 00 7c 06 00 74 02 00 7c |..|.....|.|..t..||
|00004070| 07 00 7c 06 00 7c 01 00 | 17 83 02 00 66 05 00 7c |..|..|..|....f..||
|00004080| 02 00 64 04 00 3c 6e 00 | 00 7c 01 00 7c 01 00 17 |..d..<n.|.|..|...|
|00004090| 7d 08 00 67 00 00 7d 09 | 00 78 c0 00 7c 02 00 44 |}..g..}.|.x..|..D|
|000040a0| 5d b8 00 5c 05 00 7d 03 | 00 7d 04 00 7d 05 00 7d |]..\..}.|.}..}..}|
|000040b0| 06 00 7d 07 00 7c 03 00 | 64 01 00 6b 02 00 72 97 |..}..|..|d..k..r.|
|000040c0| 01 7c 05 00 7c 04 00 18 | 7c 08 00 6b 04 00 72 97 |.|..|...||..k..r.|
|000040d0| 01 7c 09 00 6a 03 00 7c | 03 00 7c 04 00 74 02 00 |.|..j..||..|..t..|
|000040e0| 7c 05 00 7c 04 00 7c 01 | 00 17 83 02 00 7c 06 00 ||..|..|.|.....|..|
|000040f0| 74 02 00 7c 07 00 7c 06 | 00 7c 01 00 17 83 02 00 |t..|..|.|.|......|
|00004100| 66 05 00 83 01 00 01 7c | 09 00 56 01 67 00 00 7d |f......||..V.g..}|
|00004110| 09 00 74 01 00 7c 04 00 | 7c 05 00 7c 01 00 18 83 |..t..|..||..|....|
|00004120| 02 00 74 01 00 7c 06 00 | 7c 07 00 7c 01 00 18 83 |..t..|..||..|....|
|00004130| 02 00 02 7d 04 00 7d 06 | 00 6e 00 00 7c 09 00 6a |...}..}.|.n..|..j|
|00004140| 03 00 7c 03 00 7c 04 00 | 7c 05 00 7c 06 00 7c 07 |..|..|..||..|..|.|
|00004150| 00 66 05 00 83 01 00 01 | 71 fb 00 57 7c 09 00 72 |.f......|q..W|..r|
|00004160| ec 01 74 04 00 7c 09 00 | 83 01 00 64 03 00 6b 02 |..t..|..|...d..k.|
|00004170| 00 6f e0 01 7c 09 00 64 | 02 00 19 64 02 00 19 64 |.o..|..d|...d...d|
|00004180| 01 00 6b 02 00 0c 72 ec | 01 7c 09 00 56 01 6e 00 |..k...r.|.|..V.n.|
|00004190| 00 64 05 00 53 28 07 00 | 00 00 73 d4 03 00 00 20 |.d..S(..|..s.... |
|000041a0| 49 73 6f 6c 61 74 65 20 | 63 68 61 6e 67 65 20 63 |Isolate |change c|
|000041b0| 6c 75 73 74 65 72 73 20 | 62 79 20 65 6c 69 6d 69 |lusters |by elimi|
|000041c0| 6e 61 74 69 6e 67 20 72 | 61 6e 67 65 73 20 77 69 |nating r|anges wi|
|000041d0| 74 68 20 6e 6f 20 63 68 | 61 6e 67 65 73 2e 0a 0a |th no ch|anges...|
|000041e0| 20 20 20 20 20 20 20 20 | 52 65 74 75 72 6e 20 61 | |Return a|
|000041f0| 20 67 65 6e 65 72 61 74 | 6f 72 20 6f 66 20 67 72 | generat|or of gr|
|00004200| 6f 75 70 73 20 77 69 74 | 68 20 75 70 20 74 6f 20 |oups wit|h up to |
|00004210| 6e 20 6c 69 6e 65 73 20 | 6f 66 20 63 6f 6e 74 65 |n lines |of conte|
|00004220| 78 74 2e 0a 20 20 20 20 | 20 20 20 20 45 61 63 68 |xt.. | Each|
|00004230| 20 67 72 6f 75 70 20 69 | 73 20 69 6e 20 74 68 65 | group i|s in the|
|00004240| 20 73 61 6d 65 20 66 6f | 72 6d 61 74 20 61 73 20 | same fo|rmat as |
|00004250| 72 65 74 75 72 6e 65 64 | 20 62 79 20 67 65 74 5f |returned| by get_|
|00004260| 6f 70 63 6f 64 65 73 28 | 29 2e 0a 0a 20 20 20 20 |opcodes(|)... |
|00004270| 20 20 20 20 3e 3e 3e 20 | 66 72 6f 6d 20 70 70 72 | >>> |from ppr|
|00004280| 69 6e 74 20 69 6d 70 6f | 72 74 20 70 70 72 69 6e |int impo|rt pprin|
|00004290| 74 0a 20 20 20 20 20 20 | 20 20 3e 3e 3e 20 61 20 |t. | >>> a |
|000042a0| 3d 20 6d 61 70 28 73 74 | 72 2c 20 72 61 6e 67 65 |= map(st|r, range|
|000042b0| 28 31 2c 34 30 29 29 0a | 20 20 20 20 20 20 20 20 |(1,40)).| |
|000042c0| 3e 3e 3e 20 62 20 3d 20 | 61 5b 3a 5d 0a 20 20 20 |>>> b = |a[:]. |
|000042d0| 20 20 20 20 20 3e 3e 3e | 20 62 5b 38 3a 38 5d 20 | >>>| b[8:8] |
|000042e0| 3d 20 5b 27 69 27 5d 20 | 20 20 20 20 23 20 4d 61 |= ['i'] | # Ma|
|000042f0| 6b 65 20 61 6e 20 69 6e | 73 65 72 74 69 6f 6e 0a |ke an in|sertion.|
|00004300| 20 20 20 20 20 20 20 20 | 3e 3e 3e 20 62 5b 32 30 | |>>> b[20|
|00004310| 5d 20 2b 3d 20 27 78 27 | 20 20 20 20 20 20 20 23 |] += 'x'| #|
|00004320| 20 4d 61 6b 65 20 61 20 | 72 65 70 6c 61 63 65 6d | Make a |replacem|
|00004330| 65 6e 74 0a 20 20 20 20 | 20 20 20 20 3e 3e 3e 20 |ent. | >>> |
|00004340| 62 5b 32 33 3a 32 38 5d | 20 3d 20 5b 5d 20 20 20 |b[23:28]| = [] |
|00004350| 20 20 20 23 20 4d 61 6b | 65 20 61 20 64 65 6c 65 | # Mak|e a dele|
|00004360| 74 69 6f 6e 0a 20 20 20 | 20 20 20 20 20 3e 3e 3e |tion. | >>>|
|00004370| 20 62 5b 33 30 5d 20 2b | 3d 20 27 79 27 20 20 20 | b[30] +|= 'y' |
|00004380| 20 20 20 20 23 20 4d 61 | 6b 65 20 61 6e 6f 74 68 | # Ma|ke anoth|
|00004390| 65 72 20 72 65 70 6c 61 | 63 65 6d 65 6e 74 0a 20 |er repla|cement. |
|000043a0| 20 20 20 20 20 20 20 3e | 3e 3e 20 70 70 72 69 6e | >|>> pprin|
|000043b0| 74 28 6c 69 73 74 28 53 | 65 71 75 65 6e 63 65 4d |t(list(S|equenceM|
|000043c0| 61 74 63 68 65 72 28 4e | 6f 6e 65 2c 61 2c 62 29 |atcher(N|one,a,b)|
|000043d0| 2e 67 65 74 5f 67 72 6f | 75 70 65 64 5f 6f 70 63 |.get_gro|uped_opc|
|000043e0| 6f 64 65 73 28 29 29 29 | 0a 20 20 20 20 20 20 20 |odes()))|. |
|000043f0| 20 5b 5b 28 27 65 71 75 | 61 6c 27 2c 20 35 2c 20 | [[('equ|al', 5, |
|00004400| 38 2c 20 35 2c 20 38 29 | 2c 20 28 27 69 6e 73 65 |8, 5, 8)|, ('inse|
|00004410| 72 74 27 2c 20 38 2c 20 | 38 2c 20 38 2c 20 39 29 |rt', 8, |8, 8, 9)|
|00004420| 2c 20 28 27 65 71 75 61 | 6c 27 2c 20 38 2c 20 31 |, ('equa|l', 8, 1|
|00004430| 31 2c 20 39 2c 20 31 32 | 29 5d 2c 0a 20 20 20 20 |1, 9, 12|)],. |
|00004440| 20 20 20 20 20 5b 28 27 | 65 71 75 61 6c 27 2c 20 | [('|equal', |
|00004450| 31 36 2c 20 31 39 2c 20 | 31 37 2c 20 32 30 29 2c |16, 19, |17, 20),|
|00004460| 0a 20 20 20 20 20 20 20 | 20 20 20 28 27 72 65 70 |. | ('rep|
|00004470| 6c 61 63 65 27 2c 20 31 | 39 2c 20 32 30 2c 20 32 |lace', 1|9, 20, 2|
|00004480| 30 2c 20 32 31 29 2c 0a | 20 20 20 20 20 20 20 20 |0, 21),.| |
|00004490| 20 20 28 27 65 71 75 61 | 6c 27 2c 20 32 30 2c 20 | ('equa|l', 20, |
|000044a0| 32 32 2c 20 32 31 2c 20 | 32 33 29 2c 0a 20 20 20 |22, 21, |23),. |
|000044b0| 20 20 20 20 20 20 20 28 | 27 64 65 6c 65 74 65 27 | (|'delete'|
|000044c0| 2c 20 32 32 2c 20 32 37 | 2c 20 32 33 2c 20 32 33 |, 22, 27|, 23, 23|
|000044d0| 29 2c 0a 20 20 20 20 20 | 20 20 20 20 20 28 27 65 |),. | ('e|
|000044e0| 71 75 61 6c 27 2c 20 32 | 37 2c 20 33 30 2c 20 32 |qual', 2|7, 30, 2|
|000044f0| 33 2c 20 32 36 29 5d 2c | 0a 20 20 20 20 20 20 20 |3, 26)],|. |
|00004500| 20 20 5b 28 27 65 71 75 | 61 6c 27 2c 20 33 31 2c | [('equ|al', 31,|
|00004510| 20 33 34 2c 20 32 37 2c | 20 33 30 29 2c 0a 20 20 | 34, 27,| 30),. |
|00004520| 20 20 20 20 20 20 20 20 | 28 27 72 65 70 6c 61 63 | |('replac|
|00004530| 65 27 2c 20 33 34 2c 20 | 33 35 2c 20 33 30 2c 20 |e', 34, |35, 30, |
|00004540| 33 31 29 2c 0a 20 20 20 | 20 20 20 20 20 20 20 28 |31),. | (|
|00004550| 27 65 71 75 61 6c 27 2c | 20 33 35 2c 20 33 38 2c |'equal',| 35, 38,|
|00004560| 20 33 31 2c 20 33 34 29 | 5d 5d 0a 20 20 20 20 20 | 31, 34)|]]. |
|00004570| 20 20 20 52 58 00 00 00 | 69 00 00 00 00 69 01 00 | RX...|i....i..|
|00004580| 00 00 69 ff ff ff ff 4e | 28 05 00 00 00 73 05 00 |..i....N|(....s..|
|00004590| 00 00 65 71 75 61 6c 69 | 00 00 00 00 69 01 00 00 |..equali|....i...|
|000045a0| 00 69 00 00 00 00 69 01 | 00 00 00 28 05 00 00 00 |.i....i.|...(....|
|000045b0| 52 5e 00 00 00 74 03 00 | 00 00 6d 61 78 74 03 00 |R^...t..|..maxt..|
|000045c0| 00 00 6d 69 6e 52 22 00 | 00 00 52 27 00 00 00 28 |..minR".|..R'...(|
|000045d0| 0a 00 00 00 52 17 00 00 | 00 52 31 00 00 00 74 05 |....R...|.R1...t.|
|000045e0| 00 00 00 63 6f 64 65 73 | 52 5d 00 00 00 52 4d 00 |...codes|R]...RM.|
|000045f0| 00 00 52 51 00 00 00 52 | 4e 00 00 00 52 52 00 00 |..RQ...R|N...RR..|
|00004600| 00 74 02 00 00 00 6e 6e | 74 05 00 00 00 67 72 6f |.t....nn|t....gro|
|00004610| 75 70 28 00 00 00 00 28 | 00 00 00 00 73 0b 00 00 |up(....(|....s...|
|00004620| 00 64 69 66 66 6c 69 62 | 2e 70 79 63 74 13 00 00 |.difflib|.pyct...|
|00004630| 00 67 65 74 5f 67 72 6f | 75 70 65 64 5f 6f 70 63 |.get_gro|uped_opc|
|00004640| 6f 64 65 73 4a 02 00 00 | 73 28 00 00 00 00 19 0c |odesJ...|s(......|
|00004650| 01 06 01 0c 02 14 01 19 | 01 36 01 14 01 19 01 36 |........|.6.....6|
|00004660| 02 0a 01 06 01 1c 03 1c | 01 36 01 05 01 06 01 2a |........|.6.....*|
|00004670| 01 20 01 2d 01 63 01 00 | 00 00 02 00 00 00 05 00 |. .-.c..|........|
|00004680| 00 00 43 00 00 00 73 3e | 00 00 00 74 00 00 64 01 |..C...s>|...t..d.|
|00004690| 00 84 00 00 7c 00 00 6a | 01 00 83 00 00 64 02 00 |....|..j|.....d..|
|000046a0| 83 03 00 7d 01 00 74 02 | 00 7c 01 00 74 03 00 7c |...}..t.|.|..t..||
|000046b0| 00 00 6a 04 00 83 01 00 | 74 03 00 7c 00 00 6a 05 |..j.....|t..|..j.|
|000046c0| 00 83 01 00 17 83 02 00 | 53 28 03 00 00 00 73 d2 |........|S(....s.|
|000046d0| 02 00 00 52 65 74 75 72 | 6e 20 61 20 6d 65 61 73 |...Retur|n a meas|
|000046e0| 75 72 65 20 6f 66 20 74 | 68 65 20 73 65 71 75 65 |ure of t|he seque|
|000046f0| 6e 63 65 73 27 20 73 69 | 6d 69 6c 61 72 69 74 79 |nces' si|milarity|
|00004700| 20 28 66 6c 6f 61 74 20 | 69 6e 20 5b 30 2c 31 5d | (float |in [0,1]|
|00004710| 29 2e 0a 0a 20 20 20 20 | 20 20 20 20 57 68 65 72 |)... | Wher|
|00004720| 65 20 54 20 69 73 20 74 | 68 65 20 74 6f 74 61 6c |e T is t|he total|
|00004730| 20 6e 75 6d 62 65 72 20 | 6f 66 20 65 6c 65 6d 65 | number |of eleme|
|00004740| 6e 74 73 20 69 6e 20 62 | 6f 74 68 20 73 65 71 75 |nts in b|oth sequ|
|00004750| 65 6e 63 65 73 2c 20 61 | 6e 64 0a 20 20 20 20 20 |ences, a|nd. |
|00004760| 20 20 20 4d 20 69 73 20 | 74 68 65 20 6e 75 6d 62 | M is |the numb|
|00004770| 65 72 20 6f 66 20 6d 61 | 74 63 68 65 73 2c 20 74 |er of ma|tches, t|
|00004780| 68 69 73 20 69 73 20 32 | 2e 30 2a 4d 20 2f 20 54 |his is 2|.0*M / T|
|00004790| 2e 0a 20 20 20 20 20 20 | 20 20 4e 6f 74 65 20 74 |.. | Note t|
|000047a0| 68 61 74 20 74 68 69 73 | 20 69 73 20 31 20 69 66 |hat this| is 1 if|
|000047b0| 20 74 68 65 20 73 65 71 | 75 65 6e 63 65 73 20 61 | the seq|uences a|
|000047c0| 72 65 20 69 64 65 6e 74 | 69 63 61 6c 2c 20 61 6e |re ident|ical, an|
|000047d0| 64 20 30 20 69 66 0a 20 | 20 20 20 20 20 20 20 74 |d 0 if. | t|
|000047e0| 68 65 79 20 68 61 76 65 | 20 6e 6f 74 68 69 6e 67 |hey have| nothing|
|000047f0| 20 69 6e 20 63 6f 6d 6d | 6f 6e 2e 0a 0a 20 20 20 | in comm|on... |
|00004800| 20 20 20 20 20 2e 72 61 | 74 69 6f 28 29 20 69 73 | .ra|tio() is|
|00004810| 20 65 78 70 65 6e 73 69 | 76 65 20 74 6f 20 63 6f | expensi|ve to co|
|00004820| 6d 70 75 74 65 20 69 66 | 20 79 6f 75 20 68 61 76 |mpute if| you hav|
|00004830| 65 6e 27 74 20 61 6c 72 | 65 61 64 79 20 63 6f 6d |en't alr|eady com|
|00004840| 70 75 74 65 64 0a 20 20 | 20 20 20 20 20 20 2e 67 |puted. | .g|
|00004850| 65 74 5f 6d 61 74 63 68 | 69 6e 67 5f 62 6c 6f 63 |et_match|ing_bloc|
|00004860| 6b 73 28 29 20 6f 72 20 | 2e 67 65 74 5f 6f 70 63 |ks() or |.get_opc|
|00004870| 6f 64 65 73 28 29 2c 20 | 69 6e 20 77 68 69 63 68 |odes(), |in which|
|00004880| 20 63 61 73 65 20 79 6f | 75 20 6d 61 79 0a 20 20 | case yo|u may. |
|00004890| 20 20 20 20 20 20 77 61 | 6e 74 20 74 6f 20 74 72 | wa|nt to tr|
|000048a0| 79 20 2e 71 75 69 63 6b | 5f 72 61 74 69 6f 28 29 |y .quick|_ratio()|
|000048b0| 20 6f 72 20 2e 72 65 61 | 6c 5f 71 75 69 63 6b 5f | or .rea|l_quick_|
|000048c0| 72 61 74 69 6f 28 29 20 | 66 69 72 73 74 20 74 6f |ratio() |first to|
|000048d0| 20 67 65 74 20 61 6e 0a | 20 20 20 20 20 20 20 20 | get an.| |
|000048e0| 75 70 70 65 72 20 62 6f | 75 6e 64 2e 0a 0a 20 20 |upper bo|und... |
|000048f0| 20 20 20 20 20 20 3e 3e | 3e 20 73 20 3d 20 53 65 | >>|> s = Se|
|00004900| 71 75 65 6e 63 65 4d 61 | 74 63 68 65 72 28 4e 6f |quenceMa|tcher(No|
|00004910| 6e 65 2c 20 22 61 62 63 | 64 22 2c 20 22 62 63 64 |ne, "abc|d", "bcd|
|00004920| 65 22 29 0a 20 20 20 20 | 20 20 20 20 3e 3e 3e 20 |e"). | >>> |
|00004930| 73 2e 72 61 74 69 6f 28 | 29 0a 20 20 20 20 20 20 |s.ratio(|). |
|00004940| 20 20 30 2e 37 35 0a 20 | 20 20 20 20 20 20 20 3e | 0.75. | >|
|00004950| 3e 3e 20 73 2e 71 75 69 | 63 6b 5f 72 61 74 69 6f |>> s.qui|ck_ratio|
|00004960| 28 29 0a 20 20 20 20 20 | 20 20 20 30 2e 37 35 0a |(). | 0.75.|
|00004970| 20 20 20 20 20 20 20 20 | 3e 3e 3e 20 73 2e 72 65 | |>>> s.re|
|00004980| 61 6c 5f 71 75 69 63 6b | 5f 72 61 74 69 6f 28 29 |al_quick|_ratio()|
|00004990| 0a 20 20 20 20 20 20 20 | 20 31 2e 30 0a 20 20 20 |. | 1.0. |
|000049a0| 20 20 20 20 20 63 02 00 | 00 00 02 00 00 00 03 00 | c..|........|
|000049b0| 00 00 53 00 00 00 73 0c | 00 00 00 7c 00 00 7c 01 |..S...s.|...|..|.|
|000049c0| 00 64 01 00 19 17 53 28 | 02 00 00 00 4e 69 ff ff |.d....S(|....Ni..|
|000049d0| ff ff 28 00 00 00 00 28 | 02 00 00 00 74 03 00 00 |..(....(|....t...|
|000049e0| 00 73 75 6d 74 06 00 00 | 00 74 72 69 70 6c 65 28 |.sumt...|.triple(|
|000049f0| 00 00 00 00 28 00 00 00 | 00 73 0b 00 00 00 64 69 |....(...|.s....di|
|00004a00| 66 66 6c 69 62 2e 70 79 | 63 74 08 00 00 00 3c 6c |fflib.py|ct....<l|
|00004a10| 61 6d 62 64 61 3e 92 02 | 00 00 73 00 00 00 00 69 |ambda>..|..s....i|
|00004a20| 00 00 00 00 28 06 00 00 | 00 52 0c 00 00 00 52 54 |....(...|.R....RT|
|00004a30| 00 00 00 52 0f 00 00 00 | 52 27 00 00 00 52 13 00 |...R....|R'...R..|
|00004a40| 00 00 52 14 00 00 00 28 | 02 00 00 00 52 17 00 00 |..R....(|....R...|
|00004a50| 00 52 0d 00 00 00 28 00 | 00 00 00 28 00 00 00 00 |.R....(.|...(....|
|00004a60| 73 0b 00 00 00 64 69 66 | 66 6c 69 62 2e 70 79 63 |s....dif|flib.pyc|
|00004a70| 74 05 00 00 00 72 61 74 | 69 6f 7c 02 00 00 73 06 |t....rat|io|...s.|
|00004a80| 00 00 00 00 16 09 01 12 | 01 63 01 00 00 00 07 00 |........|.c......|
|00004a90| 00 00 05 00 00 00 43 00 | 00 00 73 f5 00 00 00 7c |......C.|..s....||
|00004aa0| 00 00 6a 00 00 64 03 00 | 6b 08 00 72 4d 00 69 00 |..j..d..|k..rM.i.|
|00004ab0| 00 04 7c 00 00 5f 00 00 | 7d 01 00 78 2e 00 7c 00 |..|.._..|}..x..|.|
|00004ac0| 00 6a 02 00 44 5d 20 00 | 7d 02 00 7c 01 00 6a 03 |.j..D] .|}..|..j.|
|00004ad0| 00 7c 02 00 64 01 00 83 | 02 00 64 02 00 17 7c 01 |.|..d...|..d...|.|
|00004ae0| 00 7c 02 00 3c 71 26 00 | 57 6e 00 00 7c 00 00 6a |.|..<q&.|Wn..|..j|
|00004af0| 00 00 7d 01 00 69 00 00 | 7d 03 00 7c 03 00 6a 04 |..}..i..|}..|..j.|
|00004b00| 00 64 01 00 02 7d 04 00 | 7d 05 00 78 63 00 7c 00 |.d...}..|}..xc.|.|
|00004b10| 00 6a 05 00 44 5d 58 00 | 7d 02 00 7c 04 00 7c 02 |.j..D]X.|}..|..|.|
|00004b20| 00 83 01 00 72 95 00 7c | 03 00 7c 02 00 19 7d 06 |....r..||..|...}.|
|00004b30| 00 6e 12 00 7c 01 00 6a | 03 00 7c 02 00 64 01 00 |.n..|..j|..|..d..|
|00004b40| 83 02 00 7d 06 00 7c 06 | 00 64 02 00 18 7c 03 00 |...}..|.|.d...|..|
|00004b50| 7c 02 00 3c 7c 06 00 64 | 01 00 6b 04 00 72 76 00 ||..<|..d|..k..rv.|
|00004b60| 7c 05 00 64 02 00 17 7d | 05 00 71 76 00 71 76 00 ||..d...}|..qv.qv.|
|00004b70| 57 74 06 00 7c 05 00 74 | 07 00 7c 00 00 6a 05 00 |Wt..|..t|..|..j..|
|00004b80| 83 01 00 74 07 00 7c 00 | 00 6a 02 00 83 01 00 17 |...t..|.|.j......|
|00004b90| 83 02 00 53 28 04 00 00 | 00 73 a9 00 00 00 52 65 |...S(...|.s....Re|
|00004ba0| 74 75 72 6e 20 61 6e 20 | 75 70 70 65 72 20 62 6f |turn an |upper bo|
|00004bb0| 75 6e 64 20 6f 6e 20 72 | 61 74 69 6f 28 29 20 72 |und on r|atio() r|
|00004bc0| 65 6c 61 74 69 76 65 6c | 79 20 71 75 69 63 6b 6c |elativel|y quickl|
|00004bd0| 79 2e 0a 0a 20 20 20 20 | 20 20 20 20 54 68 69 73 |y... | This|
|00004be0| 20 69 73 6e 27 74 20 64 | 65 66 69 6e 65 64 20 62 | isn't d|efined b|
|00004bf0| 65 79 6f 6e 64 20 74 68 | 61 74 20 69 74 20 69 73 |eyond th|at it is|
|00004c00| 20 61 6e 20 75 70 70 65 | 72 20 62 6f 75 6e 64 20 | an uppe|r bound |
|00004c10| 6f 6e 20 2e 72 61 74 69 | 6f 28 29 2c 20 61 6e 64 |on .rati|o(), and|
|00004c20| 0a 20 20 20 20 20 20 20 | 20 69 73 20 66 61 73 74 |. | is fast|
|00004c30| 65 72 20 74 6f 20 63 6f | 6d 70 75 74 65 2e 0a 20 |er to co|mpute.. |
|00004c40| 20 20 20 20 20 20 20 69 | 00 00 00 00 69 01 00 00 | i|....i...|
|00004c50| 00 4e 28 08 00 00 00 52 | 1d 00 00 00 52 12 00 00 |.N(....R|....R...|
|00004c60| 00 52 14 00 00 00 52 36 | 00 00 00 52 29 00 00 00 |.R....R6|...R)...|
|00004c70| 52 13 00 00 00 52 0f 00 | 00 00 52 27 00 00 00 28 |R....R..|..R'...(|
|00004c80| 07 00 00 00 52 17 00 00 | 00 52 1d 00 00 00 52 2d |....R...|.R....R-|
|00004c90| 00 00 00 74 05 00 00 00 | 61 76 61 69 6c 74 08 00 |...t....|availt..|
|00004ca0| 00 00 61 76 61 69 6c 68 | 61 73 52 0d 00 00 00 74 |..availh|asR....t|
|00004cb0| 04 00 00 00 6e 75 6d 62 | 28 00 00 00 00 28 00 00 |....numb|(....(..|
|00004cc0| 00 00 73 0b 00 00 00 64 | 69 66 66 6c 69 62 2e 70 |..s....d|ifflib.p|
|00004cd0| 79 63 74 0b 00 00 00 71 | 75 69 63 6b 5f 72 61 74 |yct....q|uick_rat|
|00004ce0| 69 6f 96 02 00 00 73 1e | 00 00 00 00 0a 0f 01 0d |io....s.|........|
|00004cf0| 01 10 01 21 01 09 03 06 | 01 10 01 10 01 0c 01 0d |...!....|........|
|00004d00| 02 12 01 0e 01 0c 01 11 | 01 63 01 00 00 00 03 00 |........|.c......|
|00004d10| 00 00 04 00 00 00 43 00 | 00 00 73 39 00 00 00 74 |......C.|..s9...t|
|00004d20| 00 00 7c 00 00 6a 01 00 | 83 01 00 74 00 00 7c 00 |..|..j..|...t..|.|
|00004d30| 00 6a 02 00 83 01 00 02 | 7d 01 00 7d 02 00 74 03 |.j......|}..}..t.|
|00004d40| 00 74 04 00 7c 01 00 7c | 02 00 83 02 00 7c 01 00 |.t..|..||.....|..|
|00004d50| 7c 02 00 17 83 02 00 53 | 28 01 00 00 00 73 ca 00 ||......S|(....s..|
|00004d60| 00 00 52 65 74 75 72 6e | 20 61 6e 20 75 70 70 65 |..Return| an uppe|
|00004d70| 72 20 62 6f 75 6e 64 20 | 6f 6e 20 72 61 74 69 6f |r bound |on ratio|
|00004d80| 28 29 20 76 65 72 79 20 | 71 75 69 63 6b 6c 79 2e |() very |quickly.|
|00004d90| 0a 0a 20 20 20 20 20 20 | 20 20 54 68 69 73 20 69 |.. | This i|
|00004da0| 73 6e 27 74 20 64 65 66 | 69 6e 65 64 20 62 65 79 |sn't def|ined bey|
|00004db0| 6f 6e 64 20 74 68 61 74 | 20 69 74 20 69 73 20 61 |ond that| it is a|
|00004dc0| 6e 20 75 70 70 65 72 20 | 62 6f 75 6e 64 20 6f 6e |n upper |bound on|
|00004dd0| 20 2e 72 61 74 69 6f 28 | 29 2c 20 61 6e 64 0a 20 | .ratio(|), and. |
|00004de0| 20 20 20 20 20 20 20 69 | 73 20 66 61 73 74 65 72 | i|s faster|
|00004df0| 20 74 6f 20 63 6f 6d 70 | 75 74 65 20 74 68 61 6e | to comp|ute than|
|00004e00| 20 65 69 74 68 65 72 20 | 2e 72 61 74 69 6f 28 29 | either |.ratio()|
|00004e10| 20 6f 72 20 2e 71 75 69 | 63 6b 5f 72 61 74 69 6f | or .qui|ck_ratio|
|00004e20| 28 29 2e 0a 20 20 20 20 | 20 20 20 20 28 05 00 00 |().. | (...|
|00004e30| 00 52 27 00 00 00 52 13 | 00 00 00 52 14 00 00 00 |.R'...R.|...R....|
|00004e40| 52 0f 00 00 00 52 60 00 | 00 00 28 03 00 00 00 52 |R....R`.|..(....R|
|00004e50| 17 00 00 00 52 49 00 00 | 00 52 4a 00 00 00 28 00 |....RI..|.RJ...(.|
|00004e60| 00 00 00 28 00 00 00 00 | 73 0b 00 00 00 64 69 66 |...(....|s....dif|
|00004e70| 66 6c 69 62 2e 70 79 63 | 74 10 00 00 00 72 65 61 |flib.pyc|t....rea|
|00004e80| 6c 5f 71 75 69 63 6b 5f | 72 61 74 69 6f b3 02 00 |l_quick_|ratio...|
|00004e90| 00 73 04 00 00 00 00 07 | 1f 03 4e 28 11 00 00 00 |.s......|..N(....|
|00004ea0| 74 08 00 00 00 5f 5f 6e | 61 6d 65 5f 5f 74 0a 00 |t....__n|ame__t..|
|00004eb0| 00 00 5f 5f 6d 6f 64 75 | 6c 65 5f 5f 74 07 00 00 |..__modu|le__t...|
|00004ec0| 00 5f 5f 64 6f 63 5f 5f | 52 12 00 00 00 74 04 00 |.__doc__|R....t..|
|00004ed0| 00 00 54 72 75 65 52 18 | 00 00 00 52 16 00 00 00 |..TrueR.|...R....|
|00004ee0| 52 19 00 00 00 52 1a 00 | 00 00 52 1e 00 00 00 52 |R....R..|..R....R|
|00004ef0| 44 00 00 00 52 54 00 00 | 00 52 5e 00 00 00 52 64 |D...RT..|.R^...Rd|
|00004f00| 00 00 00 52 68 00 00 00 | 52 6c 00 00 00 52 6d 00 |...Rh...|Rl...Rm.|
|00004f10| 00 00 28 00 00 00 00 28 | 00 00 00 00 28 00 00 00 |..(....(|....(...|
|00004f20| 00 73 0b 00 00 00 64 69 | 66 66 6c 69 62 2e 70 79 |.s....di|fflib.py|
|00004f30| 63 52 03 00 00 00 2e 00 | 00 00 73 1a 00 00 00 06 |cR......|..s.....|
|00004f40| 6a 06 02 15 45 09 0c 09 | 1a 09 2d 09 2c 09 6e 09 |j...E...|..-.,.n.|
|00004f50| 47 09 37 0c 32 09 1a 09 | 1d 69 03 00 00 00 67 33 |G.7.2...|.i....g3|
|00004f60| 33 33 33 33 33 e3 3f 63 | 04 00 00 00 08 00 00 00 |33333.?c|........|
|00004f70| 07 00 00 00 43 00 00 00 | 73 0f 01 00 00 7c 02 00 |....C...|s....|..|
|00004f80| 64 01 00 6b 04 00 73 22 | 00 74 00 00 64 02 00 7c |d..k..s"|.t..d..||
|00004f90| 02 00 66 01 00 16 83 01 | 00 82 01 00 6e 00 00 64 |..f.....|....n..d|
|00004fa0| 03 00 7c 03 00 04 03 6b | 01 00 6f 39 00 64 04 00 |..|....k|..o9.d..|
|00004fb0| 6b 01 00 6e 02 00 02 01 | 73 54 00 74 00 00 64 05 |k..n....|sT.t..d.|
|00004fc0| 00 7c 03 00 66 01 00 16 | 83 01 00 82 01 00 6e 00 |.|..f...|......n.|
|00004fd0| 00 67 00 00 7d 04 00 74 | 01 00 83 00 00 7d 05 00 |.g..}..t|.....}..|
|00004fe0| 7c 05 00 6a 02 00 7c 00 | 00 83 01 00 01 78 6d 00 ||..j..|.|.....xm.|
|00004ff0| 7c 01 00 44 5d 65 00 7d | 06 00 7c 05 00 6a 03 00 ||..D]e.}|..|..j..|
|00005000| 7c 06 00 83 01 00 01 7c | 05 00 6a 04 00 83 00 00 ||......||..j.....|
|00005010| 7c 03 00 6b 05 00 72 77 | 00 7c 05 00 6a 05 00 83 ||..k..rw|.|..j...|
|00005020| 00 00 7c 03 00 6b 05 00 | 72 77 00 7c 05 00 6a 06 |..|..k..|rw.|..j.|
|00005030| 00 83 00 00 7c 03 00 6b | 05 00 72 77 00 7c 04 00 |....|..k|..rw.|..|
|00005040| 6a 07 00 7c 05 00 6a 06 | 00 83 00 00 7c 06 00 66 |j..|..j.|....|..f|
|00005050| 02 00 83 01 00 01 71 77 | 00 71 77 00 57 74 08 00 |......qw|.qw.Wt..|
|00005060| 6a 09 00 7c 02 00 7c 04 | 00 83 02 00 7d 04 00 67 |j..|..|.|....}..g|
|00005070| 00 00 7c 04 00 44 5d 12 | 00 5c 02 00 7d 07 00 7d |..|..D].|.\..}..}|
|00005080| 06 00 7c 06 00 5e 02 00 | 71 f9 00 53 28 06 00 00 |..|..^..|q..S(...|
|00005090| 00 73 c7 03 00 00 55 73 | 65 20 53 65 71 75 65 6e |.s....Us|e Sequen|
|000050a0| 63 65 4d 61 74 63 68 65 | 72 20 74 6f 20 72 65 74 |ceMatche|r to ret|
|000050b0| 75 72 6e 20 6c 69 73 74 | 20 6f 66 20 74 68 65 20 |urn list| of the |
|000050c0| 62 65 73 74 20 22 67 6f | 6f 64 20 65 6e 6f 75 67 |best "go|od enoug|
|000050d0| 68 22 20 6d 61 74 63 68 | 65 73 2e 0a 0a 20 20 20 |h" match|es... |
|000050e0| 20 77 6f 72 64 20 69 73 | 20 61 20 73 65 71 75 65 | word is| a seque|
|000050f0| 6e 63 65 20 66 6f 72 20 | 77 68 69 63 68 20 63 6c |nce for |which cl|
|00005100| 6f 73 65 20 6d 61 74 63 | 68 65 73 20 61 72 65 20 |ose matc|hes are |
|00005110| 64 65 73 69 72 65 64 20 | 28 74 79 70 69 63 61 6c |desired |(typical|
|00005120| 6c 79 20 61 0a 20 20 20 | 20 73 74 72 69 6e 67 29 |ly a. | string)|
|00005130| 2e 0a 0a 20 20 20 20 70 | 6f 73 73 69 62 69 6c 69 |... p|ossibili|
|00005140| 74 69 65 73 20 69 73 20 | 61 20 6c 69 73 74 20 6f |ties is |a list o|
|00005150| 66 20 73 65 71 75 65 6e | 63 65 73 20 61 67 61 69 |f sequen|ces agai|
|00005160| 6e 73 74 20 77 68 69 63 | 68 20 74 6f 20 6d 61 74 |nst whic|h to mat|
|00005170| 63 68 20 77 6f 72 64 0a | 20 20 20 20 28 74 79 70 |ch word.| (typ|
|00005180| 69 63 61 6c 6c 79 20 61 | 20 6c 69 73 74 20 6f 66 |ically a| list of|
|00005190| 20 73 74 72 69 6e 67 73 | 29 2e 0a 0a 20 20 20 20 | strings|)... |
|000051a0| 4f 70 74 69 6f 6e 61 6c | 20 61 72 67 20 6e 20 28 |Optional| arg n (|
|000051b0| 64 65 66 61 75 6c 74 20 | 33 29 20 69 73 20 74 68 |default |3) is th|
|000051c0| 65 20 6d 61 78 69 6d 75 | 6d 20 6e 75 6d 62 65 72 |e maximu|m number|
|000051d0| 20 6f 66 20 63 6c 6f 73 | 65 20 6d 61 74 63 68 65 | of clos|e matche|
|000051e0| 73 20 74 6f 0a 20 20 20 | 20 72 65 74 75 72 6e 2e |s to. | return.|
|000051f0| 20 20 6e 20 6d 75 73 74 | 20 62 65 20 3e 20 30 2e | n must| be > 0.|
|00005200| 0a 0a 20 20 20 20 4f 70 | 74 69 6f 6e 61 6c 20 61 |.. Op|tional a|
|00005210| 72 67 20 63 75 74 6f 66 | 66 20 28 64 65 66 61 75 |rg cutof|f (defau|
|00005220| 6c 74 20 30 2e 36 29 20 | 69 73 20 61 20 66 6c 6f |lt 0.6) |is a flo|
|00005230| 61 74 20 69 6e 20 5b 30 | 2c 20 31 5d 2e 20 20 50 |at in [0|, 1]. P|
|00005240| 6f 73 73 69 62 69 6c 69 | 74 69 65 73 0a 20 20 20 |ossibili|ties. |
|00005250| 20 74 68 61 74 20 64 6f | 6e 27 74 20 73 63 6f 72 | that do|n't scor|
|00005260| 65 20 61 74 20 6c 65 61 | 73 74 20 74 68 61 74 20 |e at lea|st that |
|00005270| 73 69 6d 69 6c 61 72 20 | 74 6f 20 77 6f 72 64 20 |similar |to word |
|00005280| 61 72 65 20 69 67 6e 6f | 72 65 64 2e 0a 0a 20 20 |are igno|red... |
|00005290| 20 20 54 68 65 20 62 65 | 73 74 20 28 6e 6f 20 6d | The be|st (no m|
|000052a0| 6f 72 65 20 74 68 61 6e | 20 6e 29 20 6d 61 74 63 |ore than| n) matc|
|000052b0| 68 65 73 20 61 6d 6f 6e | 67 20 74 68 65 20 70 6f |hes amon|g the po|
|000052c0| 73 73 69 62 69 6c 69 74 | 69 65 73 20 61 72 65 20 |ssibilit|ies are |
|000052d0| 72 65 74 75 72 6e 65 64 | 0a 20 20 20 20 69 6e 20 |returned|. in |
|000052e0| 61 20 6c 69 73 74 2c 20 | 73 6f 72 74 65 64 20 62 |a list, |sorted b|
|000052f0| 79 20 73 69 6d 69 6c 61 | 72 69 74 79 20 73 63 6f |y simila|rity sco|
|00005300| 72 65 2c 20 6d 6f 73 74 | 20 73 69 6d 69 6c 61 72 |re, most| similar|
|00005310| 20 66 69 72 73 74 2e 0a | 0a 20 20 20 20 3e 3e 3e | first..|. >>>|
|00005320| 20 67 65 74 5f 63 6c 6f | 73 65 5f 6d 61 74 63 68 | get_clo|se_match|
|00005330| 65 73 28 22 61 70 70 65 | 6c 22 2c 20 5b 22 61 70 |es("appe|l", ["ap|
|00005340| 65 22 2c 20 22 61 70 70 | 6c 65 22 2c 20 22 70 65 |e", "app|le", "pe|
|00005350| 61 63 68 22 2c 20 22 70 | 75 70 70 79 22 5d 29 0a |ach", "p|uppy"]).|
|00005360| 20 20 20 20 5b 27 61 70 | 70 6c 65 27 2c 20 27 61 | ['ap|ple', 'a|
|00005370| 70 65 27 5d 0a 20 20 20 | 20 3e 3e 3e 20 69 6d 70 |pe']. | >>> imp|
|00005380| 6f 72 74 20 6b 65 79 77 | 6f 72 64 20 61 73 20 5f |ort keyw|ord as _|
|00005390| 6b 65 79 77 6f 72 64 0a | 20 20 20 20 3e 3e 3e 20 |keyword.| >>> |
|000053a0| 67 65 74 5f 63 6c 6f 73 | 65 5f 6d 61 74 63 68 65 |get_clos|e_matche|
|000053b0| 73 28 22 77 68 65 65 6c | 22 2c 20 5f 6b 65 79 77 |s("wheel|", _keyw|
|000053c0| 6f 72 64 2e 6b 77 6c 69 | 73 74 29 0a 20 20 20 20 |ord.kwli|st). |
|000053d0| 5b 27 77 68 69 6c 65 27 | 5d 0a 20 20 20 20 3e 3e |['while'|]. >>|
|000053e0| 3e 20 67 65 74 5f 63 6c | 6f 73 65 5f 6d 61 74 63 |> get_cl|ose_matc|
|000053f0| 68 65 73 28 22 61 70 70 | 6c 65 22 2c 20 5f 6b 65 |hes("app|le", _ke|
|00005400| 79 77 6f 72 64 2e 6b 77 | 6c 69 73 74 29 0a 20 20 |yword.kw|list). |
|00005410| 20 20 5b 5d 0a 20 20 20 | 20 3e 3e 3e 20 67 65 74 | []. | >>> get|
|00005420| 5f 63 6c 6f 73 65 5f 6d | 61 74 63 68 65 73 28 22 |_close_m|atches("|
|00005430| 61 63 63 65 70 74 22 2c | 20 5f 6b 65 79 77 6f 72 |accept",| _keywor|
|00005440| 64 2e 6b 77 6c 69 73 74 | 29 0a 20 20 20 20 5b 27 |d.kwlist|). ['|
|00005450| 65 78 63 65 70 74 27 5d | 0a 20 20 20 20 69 00 00 |except']|. i..|
|00005460| 00 00 73 11 00 00 00 6e | 20 6d 75 73 74 20 62 65 |..s....n| must be|
|00005470| 20 3e 20 30 3a 20 25 72 | 67 00 00 00 00 00 00 00 | > 0: %r|g.......|
|00005480| 00 67 00 00 00 00 00 00 | f0 3f 73 20 00 00 00 63 |.g......|.?s ...c|
|00005490| 75 74 6f 66 66 20 6d 75 | 73 74 20 62 65 20 69 6e |utoff mu|st be in|
|000054a0| 20 5b 30 2e 30 2c 20 31 | 2e 30 5d 3a 20 25 72 28 | [0.0, 1|.0]: %r(|
|000054b0| 0a 00 00 00 74 0a 00 00 | 00 56 61 6c 75 65 45 72 |....t...|.ValueEr|
|000054c0| 72 6f 72 52 03 00 00 00 | 52 1a 00 00 00 52 19 00 |rorR....|R....R..|
|000054d0| 00 00 52 6d 00 00 00 52 | 6c 00 00 00 52 68 00 00 |..Rm...R|l...Rh..|
|000054e0| 00 52 22 00 00 00 74 05 | 00 00 00 68 65 61 70 71 |.R"...t.|...heapq|
|000054f0| 74 08 00 00 00 6e 6c 61 | 72 67 65 73 74 28 08 00 |t....nla|rgest(..|
|00005500| 00 00 74 04 00 00 00 77 | 6f 72 64 74 0d 00 00 00 |..t....w|ordt....|
|00005510| 70 6f 73 73 69 62 69 6c | 69 74 69 65 73 52 31 00 |possibil|itiesR1.|
|00005520| 00 00 74 06 00 00 00 63 | 75 74 6f 66 66 74 06 00 |..t....c|utofft..|
|00005530| 00 00 72 65 73 75 6c 74 | 74 01 00 00 00 73 52 4c |..result|t....sRL|
|00005540| 00 00 00 74 05 00 00 00 | 73 63 6f 72 65 28 00 00 |...t....|score(..|
|00005550| 00 00 28 00 00 00 00 73 | 0b 00 00 00 64 69 66 66 |..(....s|....diff|
|00005560| 6c 69 62 2e 70 79 63 52 | 00 00 00 00 bf 02 00 00 |lib.pycR|........|
|00005570| 73 1e 00 00 00 00 1d 0c | 01 16 01 1c 01 16 01 06 |s.......|........|
|00005580| 01 09 01 0d 01 0d 01 0d | 01 12 01 12 01 12 01 20 |........|....... |
|00005590| 03 12 02 63 02 00 00 00 | 04 00 00 00 03 00 00 00 |...c....|........|
|000055a0| 43 00 00 00 73 44 00 00 | 00 64 01 00 74 00 00 7c |C...sD..|.d..t..||
|000055b0| 00 00 83 01 00 02 7d 02 | 00 7d 03 00 78 2a 00 7c |......}.|.}..x*.||
|000055c0| 02 00 7c 03 00 6b 00 00 | 72 3f 00 7c 00 00 7c 02 |..|..k..|r?.|..|.|
|000055d0| 00 19 7c 01 00 6b 02 00 | 72 3f 00 7c 02 00 64 02 |..|..k..|r?.|..d.|
|000055e0| 00 37 7d 02 00 71 16 00 | 57 7c 02 00 53 28 03 00 |.7}..q..|W|..S(..|
|000055f0| 00 00 73 7d 00 00 00 0a | 20 20 20 20 52 65 74 75 |..s}....| Retu|
|00005600| 72 6e 20 6e 75 6d 62 65 | 72 20 6f 66 20 60 63 68 |rn numbe|r of `ch|
|00005610| 60 20 63 68 61 72 61 63 | 74 65 72 73 20 61 74 20 |` charac|ters at |
|00005620| 74 68 65 20 73 74 61 72 | 74 20 6f 66 20 60 6c 69 |the star|t of `li|
|00005630| 6e 65 60 2e 0a 0a 20 20 | 20 20 45 78 61 6d 70 6c |ne`... | Exampl|
|00005640| 65 3a 0a 0a 20 20 20 20 | 3e 3e 3e 20 5f 63 6f 75 |e:.. |>>> _cou|
|00005650| 6e 74 5f 6c 65 61 64 69 | 6e 67 28 27 20 20 20 61 |nt_leadi|ng(' a|
|00005660| 62 63 27 2c 20 27 20 27 | 29 0a 20 20 20 20 33 0a |bc', ' '|). 3.|
|00005670| 20 20 20 20 69 00 00 00 | 00 69 01 00 00 00 28 01 | i...|.i....(.|
|00005680| 00 00 00 52 27 00 00 00 | 28 04 00 00 00 74 04 00 |...R'...|(....t..|
|00005690| 00 00 6c 69 6e 65 74 02 | 00 00 00 63 68 52 2c 00 |..linet.|...chR,.|
|000056a0| 00 00 52 31 00 00 00 28 | 00 00 00 00 28 00 00 00 |..R1...(|....(...|
|000056b0| 00 73 0b 00 00 00 64 69 | 66 66 6c 69 62 2e 70 79 |.s....di|fflib.py|
|000056c0| 63 74 0e 00 00 00 5f 63 | 6f 75 6e 74 5f 6c 65 61 |ct...._c|ount_lea|
|000056d0| 64 69 6e 67 ef 02 00 00 | 73 08 00 00 00 00 0a 13 |ding....|s.......|
|000056e0| 01 1f 01 0e 01 63 00 00 | 00 00 00 00 00 00 03 00 |.....c..|........|
|000056f0| 00 00 42 00 00 00 73 53 | 00 00 00 65 00 00 5a 01 |..B...sS|...e..Z.|
|00005700| 00 64 00 00 5a 02 00 64 | 08 00 64 08 00 64 01 00 |.d..Z..d|..d..d..|
|00005710| 84 02 00 5a 04 00 64 02 | 00 84 00 00 5a 05 00 64 |...Z..d.|....Z..d|
|00005720| 03 00 84 00 00 5a 06 00 | 64 04 00 84 00 00 5a 07 |.....Z..|d.....Z.|
|00005730| 00 64 05 00 84 00 00 5a | 08 00 64 06 00 84 00 00 |.d.....Z|..d.....|
|00005740| 5a 09 00 64 07 00 84 00 | 00 5a 0a 00 52 53 28 09 |Z..d....|.Z..RS(.|
|00005750| 00 00 00 73 65 0d 00 00 | 0a 20 20 20 20 44 69 66 |...se...|. Dif|
|00005760| 66 65 72 20 69 73 20 61 | 20 63 6c 61 73 73 20 66 |fer is a| class f|
|00005770| 6f 72 20 63 6f 6d 70 61 | 72 69 6e 67 20 73 65 71 |or compa|ring seq|
|00005780| 75 65 6e 63 65 73 20 6f | 66 20 6c 69 6e 65 73 20 |uences o|f lines |
|00005790| 6f 66 20 74 65 78 74 2c | 20 61 6e 64 0a 20 20 20 |of text,| and. |
|000057a0| 20 70 72 6f 64 75 63 69 | 6e 67 20 68 75 6d 61 6e | produci|ng human|
|000057b0| 2d 72 65 61 64 61 62 6c | 65 20 64 69 66 66 65 72 |-readabl|e differ|
|000057c0| 65 6e 63 65 73 20 6f 72 | 20 64 65 6c 74 61 73 2e |ences or| deltas.|
|000057d0| 20 20 44 69 66 66 65 72 | 20 75 73 65 73 0a 20 20 | Differ| uses. |
|000057e0| 20 20 53 65 71 75 65 6e | 63 65 4d 61 74 63 68 65 | Sequen|ceMatche|
|000057f0| 72 20 62 6f 74 68 20 74 | 6f 20 63 6f 6d 70 61 72 |r both t|o compar|
|00005800| 65 20 73 65 71 75 65 6e | 63 65 73 20 6f 66 20 6c |e sequen|ces of l|
|00005810| 69 6e 65 73 2c 20 61 6e | 64 20 74 6f 20 63 6f 6d |ines, an|d to com|
|00005820| 70 61 72 65 0a 20 20 20 | 20 73 65 71 75 65 6e 63 |pare. | sequenc|
|00005830| 65 73 20 6f 66 20 63 68 | 61 72 61 63 74 65 72 73 |es of ch|aracters|
|00005840| 20 77 69 74 68 69 6e 20 | 73 69 6d 69 6c 61 72 20 | within |similar |
|00005850| 28 6e 65 61 72 2d 6d 61 | 74 63 68 69 6e 67 29 20 |(near-ma|tching) |
|00005860| 6c 69 6e 65 73 2e 0a 0a | 20 20 20 20 45 61 63 68 |lines...| Each|
|00005870| 20 6c 69 6e 65 20 6f 66 | 20 61 20 44 69 66 66 65 | line of| a Diffe|
|00005880| 72 20 64 65 6c 74 61 20 | 62 65 67 69 6e 73 20 77 |r delta |begins w|
|00005890| 69 74 68 20 61 20 74 77 | 6f 2d 6c 65 74 74 65 72 |ith a tw|o-letter|
|000058a0| 20 63 6f 64 65 3a 0a 0a | 20 20 20 20 20 20 20 20 | code:..| |
|000058b0| 27 2d 20 27 20 20 20 20 | 6c 69 6e 65 20 75 6e 69 |'- ' |line uni|
|000058c0| 71 75 65 20 74 6f 20 73 | 65 71 75 65 6e 63 65 20 |que to s|equence |
|000058d0| 31 0a 20 20 20 20 20 20 | 20 20 27 2b 20 27 20 20 |1. | '+ ' |
|000058e0| 20 20 6c 69 6e 65 20 75 | 6e 69 71 75 65 20 74 6f | line u|nique to|
|000058f0| 20 73 65 71 75 65 6e 63 | 65 20 32 0a 20 20 20 20 | sequenc|e 2. |
|00005900| 20 20 20 20 27 20 20 27 | 20 20 20 20 6c 69 6e 65 | ' '| line|
|00005910| 20 63 6f 6d 6d 6f 6e 20 | 74 6f 20 62 6f 74 68 20 | common |to both |
|00005920| 73 65 71 75 65 6e 63 65 | 73 0a 20 20 20 20 20 20 |sequence|s. |
|00005930| 20 20 27 3f 20 27 20 20 | 20 20 6c 69 6e 65 20 6e | '? ' | line n|
|00005940| 6f 74 20 70 72 65 73 65 | 6e 74 20 69 6e 20 65 69 |ot prese|nt in ei|
|00005950| 74 68 65 72 20 69 6e 70 | 75 74 20 73 65 71 75 65 |ther inp|ut seque|
|00005960| 6e 63 65 0a 0a 20 20 20 | 20 4c 69 6e 65 73 20 62 |nce.. | Lines b|
|00005970| 65 67 69 6e 6e 69 6e 67 | 20 77 69 74 68 20 27 3f |eginning| with '?|
|00005980| 20 27 20 61 74 74 65 6d | 70 74 20 74 6f 20 67 75 | ' attem|pt to gu|
|00005990| 69 64 65 20 74 68 65 20 | 65 79 65 20 74 6f 20 69 |ide the |eye to i|
|000059a0| 6e 74 72 61 6c 69 6e 65 | 0a 20 20 20 20 64 69 66 |ntraline|. dif|
|000059b0| 66 65 72 65 6e 63 65 73 | 2c 20 61 6e 64 20 77 65 |ferences|, and we|
|000059c0| 72 65 20 6e 6f 74 20 70 | 72 65 73 65 6e 74 20 69 |re not p|resent i|
|000059d0| 6e 20 65 69 74 68 65 72 | 20 69 6e 70 75 74 20 73 |n either| input s|
|000059e0| 65 71 75 65 6e 63 65 2e | 20 20 54 68 65 73 65 20 |equence.| These |
|000059f0| 6c 69 6e 65 73 0a 20 20 | 20 20 63 61 6e 20 62 65 |lines. | can be|
|00005a00| 20 63 6f 6e 66 75 73 69 | 6e 67 20 69 66 20 74 68 | confusi|ng if th|
|00005a10| 65 20 73 65 71 75 65 6e | 63 65 73 20 63 6f 6e 74 |e sequen|ces cont|
|00005a20| 61 69 6e 20 74 61 62 20 | 63 68 61 72 61 63 74 65 |ain tab |characte|
|00005a30| 72 73 2e 0a 0a 20 20 20 | 20 4e 6f 74 65 20 74 68 |rs... | Note th|
|00005a40| 61 74 20 44 69 66 66 65 | 72 20 6d 61 6b 65 73 20 |at Diffe|r makes |
|00005a50| 6e 6f 20 63 6c 61 69 6d | 20 74 6f 20 70 72 6f 64 |no claim| to prod|
|00005a60| 75 63 65 20 61 20 2a 6d | 69 6e 69 6d 61 6c 2a 20 |uce a *m|inimal* |
|00005a70| 64 69 66 66 2e 20 20 54 | 6f 20 74 68 65 0a 20 20 |diff. T|o the. |
|00005a80| 20 20 63 6f 6e 74 72 61 | 72 79 2c 20 6d 69 6e 69 | contra|ry, mini|
|00005a90| 6d 61 6c 20 64 69 66 66 | 73 20 61 72 65 20 6f 66 |mal diff|s are of|
|00005aa0| 74 65 6e 20 63 6f 75 6e | 74 65 72 2d 69 6e 74 75 |ten coun|ter-intu|
|00005ab0| 69 74 69 76 65 2c 20 62 | 65 63 61 75 73 65 20 74 |itive, b|ecause t|
|00005ac0| 68 65 79 20 73 79 6e 63 | 68 0a 20 20 20 20 75 70 |hey sync|h. up|
|00005ad0| 20 61 6e 79 77 68 65 72 | 65 20 70 6f 73 73 69 62 | anywher|e possib|
|00005ae0| 6c 65 2c 20 73 6f 6d 65 | 74 69 6d 65 73 20 61 63 |le, some|times ac|
|00005af0| 63 69 64 65 6e 74 61 6c | 20 6d 61 74 63 68 65 73 |cidental| matches|
|00005b00| 20 31 30 30 20 70 61 67 | 65 73 20 61 70 61 72 74 | 100 pag|es apart|
|00005b10| 2e 0a 20 20 20 20 52 65 | 73 74 72 69 63 74 69 6e |.. Re|strictin|
|00005b20| 67 20 73 79 6e 63 68 20 | 70 6f 69 6e 74 73 20 74 |g synch |points t|
|00005b30| 6f 20 63 6f 6e 74 69 67 | 75 6f 75 73 20 6d 61 74 |o contig|uous mat|
|00005b40| 63 68 65 73 20 70 72 65 | 73 65 72 76 65 73 20 73 |ches pre|serves s|
|00005b50| 6f 6d 65 20 6e 6f 74 69 | 6f 6e 20 6f 66 0a 20 20 |ome noti|on of. |
|00005b60| 20 20 6c 6f 63 61 6c 69 | 74 79 2c 20 61 74 20 74 | locali|ty, at t|
|00005b70| 68 65 20 6f 63 63 61 73 | 69 6f 6e 61 6c 20 63 6f |he occas|ional co|
|00005b80| 73 74 20 6f 66 20 70 72 | 6f 64 75 63 69 6e 67 20 |st of pr|oducing |
|00005b90| 61 20 6c 6f 6e 67 65 72 | 20 64 69 66 66 2e 0a 0a |a longer| diff...|
|00005ba0| 20 20 20 20 45 78 61 6d | 70 6c 65 3a 20 43 6f 6d | Exam|ple: Com|
|00005bb0| 70 61 72 69 6e 67 20 74 | 77 6f 20 74 65 78 74 73 |paring t|wo texts|
|00005bc0| 2e 0a 0a 20 20 20 20 46 | 69 72 73 74 20 77 65 20 |... F|irst we |
|00005bd0| 73 65 74 20 75 70 20 74 | 68 65 20 74 65 78 74 73 |set up t|he texts|
|00005be0| 2c 20 73 65 71 75 65 6e | 63 65 73 20 6f 66 20 69 |, sequen|ces of i|
|00005bf0| 6e 64 69 76 69 64 75 61 | 6c 20 73 69 6e 67 6c 65 |ndividua|l single|
|00005c00| 2d 6c 69 6e 65 20 73 74 | 72 69 6e 67 73 0a 20 20 |-line st|rings. |
|00005c10| 20 20 65 6e 64 69 6e 67 | 20 77 69 74 68 20 6e 65 | ending| with ne|
|00005c20| 77 6c 69 6e 65 73 20 28 | 73 75 63 68 20 73 65 71 |wlines (|such seq|
|00005c30| 75 65 6e 63 65 73 20 63 | 61 6e 20 61 6c 73 6f 20 |uences c|an also |
|00005c40| 62 65 20 6f 62 74 61 69 | 6e 65 64 20 66 72 6f 6d |be obtai|ned from|
|00005c50| 20 74 68 65 0a 20 20 20 | 20 60 72 65 61 64 6c 69 | the. | `readli|
|00005c60| 6e 65 73 28 29 60 20 6d | 65 74 68 6f 64 20 6f 66 |nes()` m|ethod of|
|00005c70| 20 66 69 6c 65 2d 6c 69 | 6b 65 20 6f 62 6a 65 63 | file-li|ke objec|
|00005c80| 74 73 29 3a 0a 0a 20 20 | 20 20 3e 3e 3e 20 74 65 |ts):.. | >>> te|
|00005c90| 78 74 31 20 3d 20 27 27 | 27 20 20 31 2e 20 42 65 |xt1 = ''|' 1. Be|
|00005ca0| 61 75 74 69 66 75 6c 20 | 69 73 20 62 65 74 74 65 |autiful |is bette|
|00005cb0| 72 20 74 68 61 6e 20 75 | 67 6c 79 2e 0a 20 20 20 |r than u|gly.. |
|00005cc0| 20 2e 2e 2e 20 20 20 32 | 2e 20 45 78 70 6c 69 63 | ... 2|. Explic|
|00005cd0| 69 74 20 69 73 20 62 65 | 74 74 65 72 20 74 68 61 |it is be|tter tha|
|00005ce0| 6e 20 69 6d 70 6c 69 63 | 69 74 2e 0a 20 20 20 20 |n implic|it.. |
|00005cf0| 2e 2e 2e 20 20 20 33 2e | 20 53 69 6d 70 6c 65 20 |... 3.| Simple |
|00005d00| 69 73 20 62 65 74 74 65 | 72 20 74 68 61 6e 20 63 |is bette|r than c|
|00005d10| 6f 6d 70 6c 65 78 2e 0a | 20 20 20 20 2e 2e 2e 20 |omplex..| ... |
|00005d20| 20 20 34 2e 20 43 6f 6d | 70 6c 65 78 20 69 73 20 | 4. Com|plex is |
|00005d30| 62 65 74 74 65 72 20 74 | 68 61 6e 20 63 6f 6d 70 |better t|han comp|
|00005d40| 6c 69 63 61 74 65 64 2e | 0a 20 20 20 20 2e 2e 2e |licated.|. ...|
|00005d50| 20 27 27 27 2e 73 70 6c | 69 74 6c 69 6e 65 73 28 | '''.spl|itlines(|
|00005d60| 31 29 0a 20 20 20 20 3e | 3e 3e 20 6c 65 6e 28 74 |1). >|>> len(t|
|00005d70| 65 78 74 31 29 0a 20 20 | 20 20 34 0a 20 20 20 20 |ext1). | 4. |
|00005d80| 3e 3e 3e 20 74 65 78 74 | 31 5b 30 5d 5b 2d 31 5d |>>> text|1[0][-1]|
|00005d90| 0a 20 20 20 20 27 5c 6e | 27 0a 20 20 20 20 3e 3e |. '\n|'. >>|
|00005da0| 3e 20 74 65 78 74 32 20 | 3d 20 27 27 27 20 20 31 |> text2 |= ''' 1|
|00005db0| 2e 20 42 65 61 75 74 69 | 66 75 6c 20 69 73 20 62 |. Beauti|ful is b|
|00005dc0| 65 74 74 65 72 20 74 68 | 61 6e 20 75 67 6c 79 2e |etter th|an ugly.|
|00005dd0| 0a 20 20 20 20 2e 2e 2e | 20 20 20 33 2e 20 20 20 |. ...| 3. |
|00005de0| 53 69 6d 70 6c 65 20 69 | 73 20 62 65 74 74 65 72 |Simple i|s better|
|00005df0| 20 74 68 61 6e 20 63 6f | 6d 70 6c 65 78 2e 0a 20 | than co|mplex.. |
|00005e00| 20 20 20 2e 2e 2e 20 20 | 20 34 2e 20 43 6f 6d 70 | ... | 4. Comp|
|00005e10| 6c 69 63 61 74 65 64 20 | 69 73 20 62 65 74 74 65 |licated |is bette|
|00005e20| 72 20 74 68 61 6e 20 63 | 6f 6d 70 6c 65 78 2e 0a |r than c|omplex..|
|00005e30| 20 20 20 20 2e 2e 2e 20 | 20 20 35 2e 20 46 6c 61 | ... | 5. Fla|
|00005e40| 74 20 69 73 20 62 65 74 | 74 65 72 20 74 68 61 6e |t is bet|ter than|
|00005e50| 20 6e 65 73 74 65 64 2e | 0a 20 20 20 20 2e 2e 2e | nested.|. ...|
|00005e60| 20 27 27 27 2e 73 70 6c | 69 74 6c 69 6e 65 73 28 | '''.spl|itlines(|
|00005e70| 31 29 0a 0a 20 20 20 20 | 4e 65 78 74 20 77 65 20 |1).. |Next we |
|00005e80| 69 6e 73 74 61 6e 74 69 | 61 74 65 20 61 20 44 69 |instanti|ate a Di|
|00005e90| 66 66 65 72 20 6f 62 6a | 65 63 74 3a 0a 0a 20 20 |ffer obj|ect:.. |
|00005ea0| 20 20 3e 3e 3e 20 64 20 | 3d 20 44 69 66 66 65 72 | >>> d |= Differ|
|00005eb0| 28 29 0a 0a 20 20 20 20 | 4e 6f 74 65 20 74 68 61 |().. |Note tha|
|00005ec0| 74 20 77 68 65 6e 20 69 | 6e 73 74 61 6e 74 69 61 |t when i|nstantia|
|00005ed0| 74 69 6e 67 20 61 20 44 | 69 66 66 65 72 20 6f 62 |ting a D|iffer ob|
|00005ee0| 6a 65 63 74 20 77 65 20 | 6d 61 79 20 70 61 73 73 |ject we |may pass|
|00005ef0| 20 66 75 6e 63 74 69 6f | 6e 73 20 74 6f 0a 20 20 | functio|ns to. |
|00005f00| 20 20 66 69 6c 74 65 72 | 20 6f 75 74 20 6c 69 6e | filter| out lin|
|00005f10| 65 20 61 6e 64 20 63 68 | 61 72 61 63 74 65 72 20 |e and ch|aracter |
|00005f20| 27 6a 75 6e 6b 27 2e 20 | 20 53 65 65 20 44 69 66 |'junk'. | See Dif|
|00005f30| 66 65 72 2e 5f 5f 69 6e | 69 74 5f 5f 20 66 6f 72 |fer.__in|it__ for|
|00005f40| 20 64 65 74 61 69 6c 73 | 2e 0a 0a 20 20 20 20 46 | details|... F|
|00005f50| 69 6e 61 6c 6c 79 2c 20 | 77 65 20 63 6f 6d 70 61 |inally, |we compa|
|00005f60| 72 65 20 74 68 65 20 74 | 77 6f 3a 0a 0a 20 20 20 |re the t|wo:.. |
|00005f70| 20 3e 3e 3e 20 72 65 73 | 75 6c 74 20 3d 20 6c 69 | >>> res|ult = li|
|00005f80| 73 74 28 64 2e 63 6f 6d | 70 61 72 65 28 74 65 78 |st(d.com|pare(tex|
|00005f90| 74 31 2c 20 74 65 78 74 | 32 29 29 0a 0a 20 20 20 |t1, text|2)).. |
|00005fa0| 20 27 72 65 73 75 6c 74 | 27 20 69 73 20 61 20 6c | 'result|' is a l|
|00005fb0| 69 73 74 20 6f 66 20 73 | 74 72 69 6e 67 73 2c 20 |ist of s|trings, |
|00005fc0| 73 6f 20 6c 65 74 27 73 | 20 70 72 65 74 74 79 2d |so let's| pretty-|
|00005fd0| 70 72 69 6e 74 20 69 74 | 3a 0a 0a 20 20 20 20 3e |print it|:.. >|
|00005fe0| 3e 3e 20 66 72 6f 6d 20 | 70 70 72 69 6e 74 20 69 |>> from |pprint i|
|00005ff0| 6d 70 6f 72 74 20 70 70 | 72 69 6e 74 20 61 73 20 |mport pp|rint as |
|00006000| 5f 70 70 72 69 6e 74 0a | 20 20 20 20 3e 3e 3e 20 |_pprint.| >>> |
|00006010| 5f 70 70 72 69 6e 74 28 | 72 65 73 75 6c 74 29 0a |_pprint(|result).|
|00006020| 20 20 20 20 5b 27 20 20 | 20 20 31 2e 20 42 65 61 | [' | 1. Bea|
|00006030| 75 74 69 66 75 6c 20 69 | 73 20 62 65 74 74 65 72 |utiful i|s better|
|00006040| 20 74 68 61 6e 20 75 67 | 6c 79 2e 5c 6e 27 2c 0a | than ug|ly.\n',.|
|00006050| 20 20 20 20 20 27 2d 20 | 20 20 32 2e 20 45 78 70 | '- | 2. Exp|
|00006060| 6c 69 63 69 74 20 69 73 | 20 62 65 74 74 65 72 20 |licit is| better |
|00006070| 74 68 61 6e 20 69 6d 70 | 6c 69 63 69 74 2e 5c 6e |than imp|licit.\n|
|00006080| 27 2c 0a 20 20 20 20 20 | 27 2d 20 20 20 33 2e 20 |',. |'- 3. |
|00006090| 53 69 6d 70 6c 65 20 69 | 73 20 62 65 74 74 65 72 |Simple i|s better|
|000060a0| 20 74 68 61 6e 20 63 6f | 6d 70 6c 65 78 2e 5c 6e | than co|mplex.\n|
|000060b0| 27 2c 0a 20 20 20 20 20 | 27 2b 20 20 20 33 2e 20 |',. |'+ 3. |
|000060c0| 20 20 53 69 6d 70 6c 65 | 20 69 73 20 62 65 74 74 | Simple| is bett|
|000060d0| 65 72 20 74 68 61 6e 20 | 63 6f 6d 70 6c 65 78 2e |er than |complex.|
|000060e0| 5c 6e 27 2c 0a 20 20 20 | 20 20 27 3f 20 20 20 20 |\n',. | '? |
|000060f0| 20 2b 2b 5c 6e 27 2c 0a | 20 20 20 20 20 27 2d 20 | ++\n',.| '- |
|00006100| 20 20 34 2e 20 43 6f 6d | 70 6c 65 78 20 69 73 20 | 4. Com|plex is |
|00006110| 62 65 74 74 65 72 20 74 | 68 61 6e 20 63 6f 6d 70 |better t|han comp|
|00006120| 6c 69 63 61 74 65 64 2e | 5c 6e 27 2c 0a 20 20 20 |licated.|\n',. |
|00006130| 20 20 27 3f 20 20 20 20 | 20 20 20 20 20 20 20 20 | '? | |
|00006140| 5e 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |^ | |
|00006150| 20 20 20 20 20 20 2d 2d | 2d 2d 20 5e 5c 6e 27 2c | --|-- ^\n',|
|00006160| 0a 20 20 20 20 20 27 2b | 20 20 20 34 2e 20 43 6f |. '+| 4. Co|
|00006170| 6d 70 6c 69 63 61 74 65 | 64 20 69 73 20 62 65 74 |mplicate|d is bet|
|00006180| 74 65 72 20 74 68 61 6e | 20 63 6f 6d 70 6c 65 78 |ter than| complex|
|00006190| 2e 5c 6e 27 2c 0a 20 20 | 20 20 20 27 3f 20 20 20 |.\n',. | '? |
|000061a0| 20 20 20 20 20 20 20 20 | 2b 2b 2b 2b 20 5e 20 20 | |++++ ^ |
|000061b0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000061c0| 20 20 20 20 5e 5c 6e 27 | 2c 0a 20 20 20 20 20 27 | ^\n'|,. '|
|000061d0| 2b 20 20 20 35 2e 20 46 | 6c 61 74 20 69 73 20 62 |+ 5. F|lat is b|
|000061e0| 65 74 74 65 72 20 74 68 | 61 6e 20 6e 65 73 74 65 |etter th|an neste|
|000061f0| 64 2e 5c 6e 27 5d 0a 0a | 20 20 20 20 41 73 20 61 |d.\n']..| As a|
|00006200| 20 73 69 6e 67 6c 65 20 | 6d 75 6c 74 69 2d 6c 69 | single |multi-li|
|00006210| 6e 65 20 73 74 72 69 6e | 67 20 69 74 20 6c 6f 6f |ne strin|g it loo|
|00006220| 6b 73 20 6c 69 6b 65 20 | 74 68 69 73 3a 0a 0a 20 |ks like |this:.. |
|00006230| 20 20 20 3e 3e 3e 20 70 | 72 69 6e 74 20 27 27 2e | >>> p|rint ''.|
|00006240| 6a 6f 69 6e 28 72 65 73 | 75 6c 74 29 2c 0a 20 20 |join(res|ult),. |
|00006250| 20 20 20 20 20 20 31 2e | 20 42 65 61 75 74 69 66 | 1.| Beautif|
|00006260| 75 6c 20 69 73 20 62 65 | 74 74 65 72 20 74 68 61 |ul is be|tter tha|
|00006270| 6e 20 75 67 6c 79 2e 0a | 20 20 20 20 2d 20 20 20 |n ugly..| - |
|00006280| 32 2e 20 45 78 70 6c 69 | 63 69 74 20 69 73 20 62 |2. Expli|cit is b|
|00006290| 65 74 74 65 72 20 74 68 | 61 6e 20 69 6d 70 6c 69 |etter th|an impli|
|000062a0| 63 69 74 2e 0a 20 20 20 | 20 2d 20 20 20 33 2e 20 |cit.. | - 3. |
|000062b0| 53 69 6d 70 6c 65 20 69 | 73 20 62 65 74 74 65 72 |Simple i|s better|
|000062c0| 20 74 68 61 6e 20 63 6f | 6d 70 6c 65 78 2e 0a 20 | than co|mplex.. |
|000062d0| 20 20 20 2b 20 20 20 33 | 2e 20 20 20 53 69 6d 70 | + 3|. Simp|
|000062e0| 6c 65 20 69 73 20 62 65 | 74 74 65 72 20 74 68 61 |le is be|tter tha|
|000062f0| 6e 20 63 6f 6d 70 6c 65 | 78 2e 0a 20 20 20 20 3f |n comple|x.. ?|
|00006300| 20 20 20 20 20 2b 2b 0a | 20 20 20 20 2d 20 20 20 | ++.| - |
|00006310| 34 2e 20 43 6f 6d 70 6c | 65 78 20 69 73 20 62 65 |4. Compl|ex is be|
|00006320| 74 74 65 72 20 74 68 61 | 6e 20 63 6f 6d 70 6c 69 |tter tha|n compli|
|00006330| 63 61 74 65 64 2e 0a 20 | 20 20 20 3f 20 20 20 20 |cated.. | ? |
|00006340| 20 20 20 20 20 20 20 20 | 5e 20 20 20 20 20 20 20 | |^ |
|00006350| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 2d 2d | | --|
|00006360| 2d 2d 20 5e 0a 20 20 20 | 20 2b 20 20 20 34 2e 20 |-- ^. | + 4. |
|00006370| 43 6f 6d 70 6c 69 63 61 | 74 65 64 20 69 73 20 62 |Complica|ted is b|
|00006380| 65 74 74 65 72 20 74 68 | 61 6e 20 63 6f 6d 70 6c |etter th|an compl|
|00006390| 65 78 2e 0a 20 20 20 20 | 3f 20 20 20 20 20 20 20 |ex.. |? |
|000063a0| 20 20 20 20 2b 2b 2b 2b | 20 5e 20 20 20 20 20 20 | ++++| ^ |
|000063b0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000063c0| 5e 0a 20 20 20 20 2b 20 | 20 20 35 2e 20 46 6c 61 |^. + | 5. Fla|
|000063d0| 74 20 69 73 20 62 65 74 | 74 65 72 20 74 68 61 6e |t is bet|ter than|
|000063e0| 20 6e 65 73 74 65 64 2e | 0a 0a 20 20 20 20 4d 65 | nested.|.. Me|
|000063f0| 74 68 6f 64 73 3a 0a 0a | 20 20 20 20 5f 5f 69 6e |thods:..| __in|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.